GetItemArrayJSONString

Syntax 1

Description

Gets the string value of the item whose type is array.

Applies to

JSONParser objects

Syntax

objectname.GetItemArrayJSONString ( ParentItemHandle, Key )

Argument

Description

objectname

The name of the JSONParser object whose array item you want to obtain.

ParentItemHandle

A long whose value is the handle of the parent item of JsonObjectItem type.

Key

A string whose value is the key of the child item of JsonArrayItem type.


Return value

String.

Returns the string value of the item if it succeeds and -1 if an error occurs. If any argument's value is null, the method returns null. If an error occurs, the method throws the exception.

Usage

If the item value is null, this function will throw an error, therefore, it is recommended that before executing this function, call GetItemType to check if the item value is null. See example 2.

Example

The following code gets the JSON string of an array according to the key name:

JsonParser lnv_JsonParser
String ls_Json, ls_Array
Long ll_RootObject
lnv_JsonParser = Create JsonParser

ls_Json = '{"id":1001, "name":"evan", "department_array":[999999, {"name":"Website"}, {"name":"PowerBuilder"}, {"name":"IT"}] }'

lnv_JsonParser.LoadString(ls_Json)
ll_RootObject = lnv_JsonParser.GetRootItem()
ls_Array = lnv_JsonParser.GetItemArrayJSONString(ll_RootObject, "department_array")

See also

GetItemArray

GetItemBlob

GetItemBoolean

GetItemByPath

GetItemDate

GetItemDateTime

GetItemNumber

GetItemObject

GetItemObjectJSONString

GetItemString

GetItemTime

GetItemType

GetNumberType

Syntax 2

Description

Gets the string value of the item whose type is array.

Applies to

JSONParser objects

Syntax

objectname.GetItemArrayJSONString ( ItemPath )

Argument

Description

objectname

The name of the JSONParser object whose array item you want to obtain.

ItemPath

A string whose value is the path of the item of JsonArrayItem type. If there is a multi-dimensional array, use the number to indicate the order of the array elements. If a key name contains "/", use the escape character "~~/" to replace "/".


Return value

String.

Returns the string value of the item if it succeeds and -1 if an error occurs. If any argument's value is null, the method returns null. If an error occurs, the method throws the exception.

Usage

If the item value is null, this function will throw an error, therefore, it is recommended that before executing this function, call GetItemType to check if the item value is null. See example 2.

Example

The following code gets the JSON string of an array according to its item path:

JsonParser lnv_JsonParser
String ls_Json, ls_Array, ls_Path
lnv_JsonParser = Create JsonParser

ls_Json = '{"id":1001, "name":"evan", "department_array":[999999, {"name":"Website"}, {"name":"PowerBuilder"}, {"name":"IT"}] }'

lnv_JsonParser.LoadString(ls_Json)
ls_Path = "/department_array"
ls_Array = lnv_JsonParser.GetItemArrayJSONString(ls_Path)

See also

GetItemArray

GetItemBlob

GetItemBoolean

GetItemByPath

GetItemDate

GetItemDateTime

GetItemNumber

GetItemObject

GetItemObjectJSONString

GetItemString

GetItemTime

GetItemType

GetNumberType

Syntax 3

Description

Gets the string value of the item whose type is array.

Applies to

JSONParser objects

Syntax

objectname.GetItemArrayJSONString ( ItemHandle )

Argument

Description

objectname

The name of the JSONParser object whose array item you want to obtain.

ItemHandle

A long value specifying the item handle which is JsonObjectItem type.


Return value

String.

Returns the string value of the item if it succeeds. If any argument's value is null, the method returns null. If an error occurs, the method throws the exception.

Usage

If the item value is null, this function will throw an error, therefore, it is recommended that before executing this function, call GetItemType to check if the item value is null. See example 2.

Example

The following code gets the JSON string of an array according to its item handle:

JsonParser lnv_JsonParser
String ls_Json, ls_Array
Long ll_RootObject, ll_ChildArray, ll_Handle
lnv_JsonParser = Create JsonParser

ls_Json = '{"id":1001, "name":"svan", "active":true,"array":[12,34,[56,78]]}'

lnv_JsonParser.LoadString(ls_Json)
ll_RootObject = lnv_JsonParser.GetRootItem()
ll_ChildArray = lnv_JsonParser.GetItemArray(ll_RootObject,"array")
ll_Handle = lnv_JsonParser.GetChildItem(ll_ChildArray, 3)
ls_Array = lnv_JsonParser.GetItemArrayJSONString(ll_Handle)

See also

GetItemArray

GetItemBlob

GetItemBoolean

GetItemByPath

GetItemDate

GetItemDateTime

GetItemNumber

GetItemObject

GetItemObjectJSONString

GetItemString

GetItemTime

GetItemType

GetNumberType