GetChildKey
PowerScript function
Description
Gets the key name of the child item in a JSON parser object.
Applies to
Syntax
|
1 |
objectname.GetChildKey ( ParentItemHandle, Index ) |
|
1 |
objectname.GetChildKey ( ParentItemPath, Index ) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the JSONParser object whose key name you want |
|
ParentItemHandle |
A long whose value is the handle of the parent item of |
|
ParentItemPath |
A string whose value is the path of the parent item of |
|
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 according to the parent
item handle and the child item index:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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) |
This example gets the key of the child item according to the parent
item path and the child item index:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
JsonParser lnv_JsonParser Long ll_id String ls_Json, ls_key, ls_name, ls_RootPath, ls_ChildPath boolean lb_active lnv_JsonParser = Create JsonParser ls_Json = '{"id":1001, "name":"evan", "active":true}' // Loads a JSON string lnv_JsonParser.LoadString(ls_Json) ls_RootPath = "/" // Gets the key of the child item ls_key = lnv_JsonParser.GetChildKey(ls_RootPath, 1) ls_ChildPath = ls_RootPath + ls_Key ll_id = lnv_JsonParser.GetItemNumber(ls_ChildPath) ls_key = lnv_JsonParser.GetChildKey(ls_RootPath, 2) ls_name = lnv_JsonParser.GetItemString(ls_RootPath + ls_key) ls_ChildPath = "/active" lb_active = lnv_JsonParser.GetItemBoolean(ls_ChildPath) |
See also