JsonObject Class Methods

In this section, the JsonObject class methods are presented in alphabetical order.

Syntax

AddJsonArray(Name, JArrObj)

Description

Use this method to add a Json array to the Json object.

Parameters

Field or Control

Definition

Name

Specifies the name of the Json array that needs to be added as a string.

JArrObj

Specifies the Json array object that needs to be added as a JsonArrayObject.

Returns

None.

Example

Local JsonObject &jobj = CreateJsonObject();
Local JsonArray &jArr = CreateJsonArray();
&jObj.AddJsonArray("MemberNames", &jArr);

Syntax

AddJsonObject(Name, JObj)

Description

Use this method to add a Json object to this Json object.

Parameters

Field or Control

Definition

Name

Specifies the name of the Json object that needs to be added as a string.

JObj

Specifies the Json object that needs to be added as a JsonObject.

Returns

None.

Example

Local JsonObject &jobj = CreateJsonObject();
Local JsonArray &jObj2 = CreateJsonArray();
&jObj.AddJsonObject("Address", &jObj);

Syntax

AddProperty(Name, Type)

Description

Use this method to add a property to the Json object.

Parameters

Field or Control

Definition

Name

Specifies the name of the property that needs to be added as a string.

Type

Specifies the type of the property that needs to be added as a string.

Returns

None.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Name", "TYPE_STRING");
&jObj.AddProperty("Id", "TYPE_INT");

Syntax

GetAsString (Name)

Description

Use this method to return the value of the input parameter object as a string.

Parameters

Field or Control

Definition

Name

Specifies the name of the object as a string.

Returns

String.

Example

Local string &output = &jObj.GetAsString("Name");

Syntax

GetBoolean(Name)

Description

Use this method to return the boolean value of the property mentioned by the input parameter.

Parameters

Field or Control

Definition

Name

Specifies the name of the Boolean object as a string.

Returns

Boolean.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Married", "TYPE_BOOLEAN");
Local Boolean &jb = &jObj.GetBoolean("Married");

Syntax

GetBooleanProperty(Name)

Description

Use this method to return the Boolean property of the object as mentioned in the input parameter.

Parameters

Field or Control

Definition

Name

Specifies the name of the Boolean property as a string.

Returns

Boolean.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Married", "TYPE_BOOLEAN");
Local boolean &bBoolProp = &jObj.GetBooleanProperty("Married");

Syntax

GetChildCount()

Description

Use this method to return the child count of the Json object.

Parameters

None.

Returns

Integer.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Name", "TYPE_STRING");
&jObj.AddProperty("Id", "TYPE_INT");
Local integer &childcount = &jObj.GetChildCount();

Syntax

GetDate(Name)

Description

Use this method to return the date value of the property mentioned by the input parameter.

Parameters

Field or Control

Definition

Name

Specifies the name of the date object as a string.

Returns

Date.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("DOB", "TYPE_DATE");
Local date &jdt = &jObj.GetDate("DOB");

Syntax

GetDateTime(Name)

Description

Use this method to return the datetime value of the property mentioned by the input parameter.

Parameters

Field or Control

Definition

Name

Specifies the name of the datetime object as a string.

Returns

DateTime.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("DT_TM", "TYPE_DATETIME");
Local datetime &jdttm = &jObj.GetDateTime("DT_TM");

Syntax

GetFloat(Name)

Description

Use this method to return the float value of the property mentioned by the input parameter.

Parameters

Field or Control

Definition

Name

Specifies the name of the float object as a string.

Returns

Float.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Expenses", "TYPE_FLOAT");
Local float &jf = &jObj.GetFloat("Expenses");

Syntax

GetInteger(Name)

Description

Use this method to return the integer value of the property mentioned by the input parameter.

Parameters

Field or Control

Definition

Name

Specifies the name of the integer object as a string.

Returns

Integer.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Id", "TYPE_INT");
Local integer &ji = &jObj.GetInteger("Id");

Syntax

GetJsonArray(Name)

Description

Use this method to return the Json array mentioned by the input parameter from the Json object.

Parameters

Field or Control

Definition

Name

Specifies the name of the Json array object as a string.

Returns

JsonArray.

Example

Local JsonObject &jObj = CreateJsonObject();
Local JsonArray &jArr = CreateJsonArray();
&jObj.AddJsonArray("MemberNames", &jArr);
Local JsonArray &ja = &jObj.GetJsonArray("MemberNames");

Syntax

GetJsonNode(Name)

Description

Use this method to return the Json node mentioned by the input parameter from the Json object.

Parameters

Field or Control

Definition

Name

Specifies the name of the Json node object as a string.

Returns

JsonNode.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Name", "TYPE_STRING");
Local JsonNode &jn = &jObj.GetJsonNode("Name");

Syntax

GetJsonObject(Name)

Description

Use this method to return the Json object mentioned by the input parameter from the Json object.

Parameters

Field or Control

Definition

Name

Specifies the name of the Json object as a string.

Returns

JsonObject.

Example

Local JsonObject &jObj = CreateJsonObject();
Local JsonObject &jObj2 = CreateJsonObject();
&jObj.AddJsonObject("Address", &jObj2);
Local JsonObject &jo = &jObj.GetJsonObject("Address");

Syntax

GetNumber(Name)

Description

Use this method to return the number value of the property mentioned by the input parameter.

Parameters

Field or Control

Definition

Name

Specifies the name of the number object as a string.

Returns

Number.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Salary", "TYPE_NUMBER");
Local Number &jn = &jObj.GetNumber("Salary");

Syntax

GetPropertyNameAt(index)

Description

Use this method to return the name of the properties at the specified index in the Json object.

Parameters

Field or Control

Definition

Index

Specifies the index in the Json object as an integer.

Returns

String.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Name", "TYPE_STRING");
&jObj.AddProperty("Id", "TYPE_INT");
Local string &propName = &jObj.GetPropertyNameAt(1);

Syntax

GetString(Name)

Description

Use this method to return the string value of the property mentioned by the input parameter.

Parameters

Field or Control

Definition

Name

Specifies the name of the string object as a string.

Returns

String.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Name", "TYPE_STRING");
Local String &js = &jObj.GetString("Name");

Syntax

GetTime(Name)

Description

Use this method to return the time value of the property mentioned by the input parameter.

Parameters

Field or Control

Definition

Name

Specifies the name of the time object as a string.

Returns

Time.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("TOB", "TYPE_TIME");
Local time &jtm = &jObj.GetTime("TOB");

Syntax

IsExist(Name)

Description

Use this method to check whether the property exists.

Parameters

Field or Control

Definition

Name

Specifies the name of the Json object that needs to be checked as a string.

Returns

Boolean.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Name", "TYPE_STRING");
Local boolean &bExist = &jObj.IsExist("Id");

Syntax

IsJsonArray(Name)

Description

Use this method to check whether the property is a Json array.

Parameters

Field or Control

Definition

Name

Specifies the name of the property that needs to be checked as a string.

Returns

Boolean.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Name", "TYPE_STRING");
Local boolean &bIsJsonArr = &jObj.IsJsonArray("Name");

Syntax

IsJsonObject(Name)

Description

Use this method to check whether the property is a Json object.

Parameters

Field or Control

Definition

Name

Specifies the name of the property that needs to be checked as a string.

Returns

Boolean.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Name", "TYPE_STRING");
Local boolean &bIsJsonObj = &jObj.IsJsonObject("Name");

Syntax

IsNullProperty(Name)

Description

Use this method to check whether the property is null or not.

Parameters

Field or Control

Definition

Name

Specifies the name of the Json object that needs to be checked as a string.

Returns

Boolean.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Name", "TYPE_STRING");
&jObj.AddProperty("Id", "TYPE_INT");
Local boolean &bNull = &jObj.IsNullProperty("Id");

Syntax

ToString()

Description

Use this method to serialize the Json object to string.

Parameters

None.

Returns

String.

Example

Local JsonObject &jObj = CreateJsonObject();
&jObj.AddProperty("Name", "TYPE_STRING");
&jObj.AddProperty("Id", "TYPE_INT");
Local string &output = &jObj.ToString();