GetItemObjectJSONString
PowerScript function
Syntax 1: GetItemObjectJSONString ( ParentItemHandle, Key )
Syntax 2: GetItemObjectJSONString ( ItemPath )
Syntax 3: GetItemObjectJSONString ( ItemHandle )
Syntax 1
Description
Gets the string value of the object item.
Applies to
Syntax
|
1 |
objectname.GetItemObjectJSONString ( 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
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 in GetItemArray.
Examples
This example gets the string value of the “date_object” object
according to the key name:
|
1 2 3 4 5 6 7 8 9 10 |
JsonParser lnv_JsonParser String ls_Json, ls_Object Long ll_RootObject 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() ls_Object = lnv_JsonParser.GetItemObjectJSONString(ll_RootObject, "date_object") |
Syntax 2
Description
Gets the string value of the object item.
Applies to
Syntax
|
1 |
objectname.GetItemObjectJSONString ( 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
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 in GetItemArray.
Examples
This example gets the string value of the “date_object” object
according to its item path:
|
1 2 3 4 5 6 7 8 9 |
JsonParser lnv_JsonParser String ls_Json, ls_Object, ls_Path 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" ls_Object = lnv_JsonParser.GetItemObjectJSONString(ls_Path) |
Syntax 3
Description
Gets the string value of the object item.
Applies to
Syntax
|
1 |
objectname.GetItemObjectJSONString ( ItemHandle ) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the JSONParser object whose child object |
|
ItemHandle |
A long specifying the item handle which is |
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 in GetItemArray.
Examples
This example gets the string value of the “datetime” object
according to its item handle:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
JsonParser lnv_JsonParser String ls_Json, ls_Object Long ll_RootObject, ll_ChildArray, ll_Handle lnv_JsonParser = Create JsonParser ls_Json = '{"id":1001, "name":"evan", "date_array":[{"datetime":7234930293, "date": "2017-09-21", "time": "12:00:00"}]}' lnv_JsonParser.LoadString(ls_Json) ll_RootObject = lnv_JsonParser.GetRootItem() ll_ChildArray = lnv_JsonParser.GetItemArray(ll_RootObject,"date_array") ll_Handle = lnv_JsonParser.GetChildItem(ll_ChildArray,1) ls_Object = lnv_JsonParser.GetItemObjectJSONString(ll_Handle) |
See also