GetItemObject
PowerScript function
Syntax 1: GetItemObject ( ParentItemHandle, Key )
Syntax 2: GetItemObject ( ItemPath )
Syntax 1
Description
Gets the handle value of the child item whose type is
object.
Applies to
Syntax
|
1 |
objectname.GetItemObject ( ParentItemHandle, Key ) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the JSONParser object whose child object |
|
ParentItemHandle |
A long whose value is the handle of the parent item of |
|
Key |
A string whose value is the key of the child item of |
Return value
Long.
Returns the handle value of the child item if it succeeds and -1
if an error occurs. If any argument’s value is null, the method returns
null.
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 in GetItemArray.
Examples
This example gets the value of the “date_object” item:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
JsonParser lnv_JsonParser String ls_Json DateTime ldt_datetime Date ldate_date Time lt_time Long ll_RootObject, ll_date_object lnv_JsonParser = Create JsonParser ls_Json = '{"id":1001, "name":"evan", "date_object":{"datetime":7234930293, "date": "2017-09-21", "time": "12:00:00"}}' lnv_JsonParser.LoadString(ls_Json) ll_RootObject = lnv_JsonParser.GetRootItem() ll_date_object = lnv_JsonParser.GetItemObject(ll_RootObject, "date_object") ldt_datetime = lnv_JsonParser.GetItemDateTime(ll_date_object , "datetime") ldate_date = lnv_JsonParser.GetItemDate(ll_date_object , "date") lt_time = lnv_JsonParser.GetItemTime(ll_date_object , "time") |
Syntax 2
Description
Gets the handle value of the child item whose type is
object.
Applies to
Syntax
|
1 |
objectname.GetItemObject ( ItemPath ) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the JSONParser object whose child object |
|
ItemPath |
A string whose value is the path of the item of |
Return value
Long.
Returns the handle value of the child item if it succeeds and -1
if an error occurs. If any argument’s value is null, the method returns
null.
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 in GetItemArray.
Examples
This example gets the “date_object” object according to its item
path and then gets the values of the “date_object” object according to
the key name:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
JsonParser lnv_JsonParser String ls_Json, ls_Path DateTime ldt_datetime Date ldate_date Time lt_time Long ll_date_object lnv_JsonParser = Create JsonParser ls_Json = '{"id":1001, "name":"evan", "date_object":{"datetime":7234930293, "date":"2017-09-21", "time":"12:00:00"}}' lnv_JsonParser.LoadString(ls_Json) ls_Path = "/date_object" ll_date_object = lnv_JsonParser.GetItemObject(ls_Path) ldt_datetime = lnv_JsonParser.GetItemDateTime(ll_date_object, "datetime") ldate_date = lnv_JsonParser.GetItemDate(ll_date_object, "date") lt_time = lnv_JsonParser.GetItemTime(ll_date_object, "time") |
See also