GetChildKey

Description

Gets the key name of the child item in a JSON parser object.

Applies to

JSONParser objects

Syntax

objectname.GetChildKey ( ParentItemHandle, Index )

Argument

Description

objectname

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

ParentItemHandle

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

Index

A long whose value is the index of the child item.


Return value

String.

Returns the key name of the child item if it succeeds and empty string ("") if an error occurs. If any argument's value is null, the method returns null.

Examples

This example gets the key of the child item:

JsonParser lnv_JsonParser
Long ll_RootObject, ll_id
String ls_Json, ls_key, ls_name
boolean lb_active
lnv_JsonParser = Create JsonParser

ls_Json = '{"id":1001, "name":"evan", "active":true}'

// Loads a JSON string
lnv_JsonParser.LoadString(ls_Json)
ll_RootObject = lnv_JsonParser.GetRootItem()

// Gets the key of the child item
ls_key = lnv_JsonParser.GetChildKey(ll_RootObject, 1)
ll_id = lnv_JsonParser.GetItemNumber(ll_RootObject, ls_key)
ls_key = lnv_JsonParser.GetChildKey(ll_RootObject, 2)
ls_name = lnv_JsonParser.GetItemString(ll_RootObject, ls_key)
ls_key = lnv_JsonParser.GetChildKey(ll_RootObject, 3)
lb_active = lnv_JsonParser.GetItemBoolean(ll_RootObject, ls_key)

See also

GetChildCount

GetChildItem