JsonNode Class Methods
In this section, the JsonNode class methods are presented in alphabetical order.
Syntax
GetBoolean()
Description
Use this method to return a Boolean value from the node.
Parameters
None.
Returns
Boolean.
Example
Local JsonNode &jNode = CreateJsonNode();
Local Boolean &myBoolean = &jNode.GetBoolean();
Syntax
GetFloat()
Description
Use this method to return the float value from the node.
Parameters
None.
Returns
Float.
Example
Local JsonNode &jNode = CreateJsonNode();
Local float &myFloat = &jNode.GetFloat();
Syntax
GetInteger()
Description
Use this method to return the integer value from the node.
Parameters
None.
Returns
Integer.
Example
Local JsonNode &jNode = CreateJsonNode();
Local integer &myInt = &jNode.GetInteger();
Syntax
GetJsonArray()
Description
Use this method to return the Json array from the node.
Parameters
None.
Returns
JsonArray.
Example
Local JsonNode &jNode = CreateJsonNode();
Local JsonArray &jArray = &jNode.GetJsonArray();
Syntax
GetJsonObject()
Description
Use this method to return the Json object from the node.
Parameters
None.
Returns
JsonObject.
Example
Local JsonNode &jNode = CreateJsonNode();
Local JsonObject &jObj = &jNode.GetJsonObject();
Syntax
GetJsonValue()
Description
Use this method to return the Json value from the node.
Parameters
None.
Returns
JsonValue.
Example
Local JsonNode &jNode = CreateJsonNode();
Local JsonValue &jValue = &jNode.GetJsonValue();
Syntax
GetNodeType()
Description
Use this method to return the type of the node.
Parameters
None.
Returns
Integer.
List of numeric values and the corresponding node types:
Numeric Value |
Node Types |
---|---|
0 |
JSON_NODE_NULL |
1 |
JSON_NODE_OBJECT |
2 |
JSON_NODE_ARRAY |
3 |
JSON_NODE_VALUE |
Example
Local JsonNode &jNode = CreateJsonNode();
Local integer &nodeType = &jNode.GetNodeType();
Syntax
GetNumber()
Description
Use this method to return the number value from the node.
Parameters
None.
Returns
Number.
Example
Local JsonNode &jNode = CreateJsonNode();
Local Number &myNumber = &jNode.GetNumber();
Syntax
GetParentNode()
Description
Use this method to return the parent node of the current node.
Parameters
None.
Returns
JsonNode.
Example
Local JsonNode &jNode = CreateJsonNode();
Local JsonNode &parentNode = &jNode.GetParentNode();
Syntax
GetString()
Description
Use this method to return the string value from the node.
Parameters
None.
Returns
String.
Example
Local JsonNode &jNode = CreateJsonNode();
Local String &myString = &jNode.GetString();
Syntax
GetValueType()
Description
Use this method to return the type of the value.
Parameters
None.
Returns
Integer.
List of numeric values and the corresponding value types.
Numeric Value |
Value Types |
---|---|
0 |
JSON_VALUE_INVALID |
1 |
JSON_VALUE_INT |
2 |
JSON_VALUE_FLOAT |
3 |
JSON_VALUE_DOUBLE |
4 |
JSON_VALUE_NUMBER |
5 |
JSON_VALUE_BOOLEAN |
6 |
JSON_VALUE_STRING |
7 |
JSON_VALUE_NULL |
8 |
JSON_VALUE_DATE |
9 |
JSON_VALUE_TIME |
10 |
JSON_VALUE_DATETIME |
Example
Local JsonNode &jNode = CreateJsonNode();
Local integer &nodeValue = &jNode.GetValueType();
Syntax
IsJsonArray()
Description
Use this method to check whether the type of the node is a JsonArray.
Parameters
None.
Returns
Boolean.
Example
Local JsonNode &jNode = CreateJsonNode();
Local Boolean &bIsJsonArr = &jNode.IsJsonArray();
Syntax
IsJsonObject()
Description
Use this method to check whether the type of the node is a JsonObject.
Parameters
None.
Returns
Boolean.
Example
Local JsonNode &jNode = CreateJsonNode();
Local Boolean &bIsJsonObj = &jNode.IsJsonObject();
Syntax
IsJsonValue()
Description
Use this method to check whether the type of the node is a JsonValue.
Parameters
None.
Returns
Boolean.
Example
Local JsonNode &jNode = CreateJsonNode();
Local Boolean &bIsJsonVal = &jNode.IsJsonValue();
Syntax
IsNull()
Description
Use this method to check whether the value of the node is null.
Parameters
None.
Returns
Boolean.
Example
Local JsonNode &jNode = CreateJsonNode();
Local Boolean &bIsNull = &jNode.IsNull();
Syntax
SetBoolean(boolean_value)
Description
Use this method to set the Boolean value of the node.
Parameters
Field or Control |
Definition |
---|---|
boolean_value |
Specifies the value of the node as a Boolean. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
&jNode.SetBoolean(True);
Syntax
SetDate(date_value)
Description
Use this method to set the date value of the node.
Parameters
Field or Control |
Definition |
---|---|
date_value |
Specifies the date value of the node as date. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
Local date &dt = Date(20000101);
&jNode.SetDate(&dt);
Syntax
SetDateTime(datetime_value)
Description
Use this method to set the datetime value of the node.
Parameters
Field or Control |
Definition |
---|---|
datetime_value |
Specifies the datetime value of the node as datetime. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
Local datetime &dttm = DateTime6(2000, 1, 1, 1, 5, 7);
&jNode.SetDateTime(&dttm);
Syntax
SetFalse()
Description
Use this method to set the value of the node to false.
Parameters
None.
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
&jNode.SetFalse();
Syntax
SetFloat(float_value)
Description
Use this method to set the float value of the node.
Parameters
Field or Control |
Definition |
---|---|
float_value |
Specifies the float value of the node as a float. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
&jNode.SetFloat(1.2);
Syntax
SetInteger(integer_value)
Description
Use this method to set the integer value of the node.
Parameters
Field or Control |
Definition |
---|---|
integer_value |
Specifies the integer value of the node as an integer. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
&jNode.SetInteger(10);
Syntax
SetJsonArray(jArray)
Description
Use this method to set the Json array of the node.
Parameters
Field or Control |
Definition |
---|---|
jArray |
Specifies the Json array of the node as a JsonArray object. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
Local JsonArray &jArr = CreateJsonArray();
&jNode.SetJsonArray(&jArr);
Syntax
SetJsonObject(Object)
Description
Use this method to set the Json object of the node.
Parameters
Field or Control |
Definition |
---|---|
Object |
Specifies the object as a JsonObject. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
Local JsonObject &jObj = CreateJsonObject();
&jNode.SetJsonObject(&jObj);
Syntax
SetJsonValue(jValue)
Description
Use this method to set the Json value of the node.
Parameters
Field or Control |
Definition |
---|---|
jValue |
Specifies the JsonValue of the node as a JsonValue object. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
Local JsonValue &jVal = CreateJsonValue();
&jNode.SetJsonValue(&jVal);
Syntax
SetNodeName(Name)
Description
Use this method to set the name of the node.
Parameters
Field or Control |
Definition |
---|---|
Name |
Specifies the name of the node as a string. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
&jNode.SetNodeName("Test Node");
Syntax
SetNull()
Description
Use this method to set the value of the node to null.
Parameters
None.
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
&jNode.SetNull();
Syntax
SetNumber(number_value)
Description
Use this method to set the number value of the node.
Parameters
Field or Control |
Definition |
---|---|
number_value |
Specifies the number value of the node as a number. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
&jNode.SetNumber(5);
Syntax
SetString(string_value)
Description
Use this method to set the string value of the node.
Parameters
Field or Control |
Definition |
---|---|
string_value |
Specifies the string value of the node as a string. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
&jNode.SetString("Test String");
Syntax
SetTime(time_value)
Description
Use this method to set the time value of the node.
Parameters
Field or Control |
Definition |
---|---|
time_value |
Specifies the time value of the node as time. |
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
Local time &tm = Time(10507);
&jNode.SetTime(&tm);
Syntax
SetTrue()
Description
Use this method to set the value of the node to true.
Parameters
None.
Returns
None.
Example
Local JsonNode &jNode = CreateJsonNode();
&jNode.SetTrue();
Syntax
ToString()
Description
Use this method to serialize the JsonNode object to string.
Parameters
None.
Returns
String.
Example
Local JsonNode &jNode = CreateJsonNode();
Local String &myJNodeStr = &jNode.ToString();