Syntax 1: GetItemObject ( ParentItemHandle, Key )
Syntax 2: GetItemObject ( ItemPath )
Description
Gets the handle value of the child item whose type is object.
Applies to
Syntax
objectname.GetItemObject ( ParentItemHandle, Key )
Argument |
Description |
---|---|
objectname |
The name of the JSONParser object whose child object 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 JsonObjectItem type. |
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:
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")
Description
Gets the handle value of the child item whose type is object.
Applies to
Syntax
objectname.GetItemObject ( ItemPath )
Argument |
Description |
---|---|
objectname |
The name of the JSONParser object whose child object item you want to obtain. |
ItemPath |
A string whose value is the path of the item of JsonObjectItem 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
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:
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