GetItemDecimal
PowerScript function
Syntax 1: GetItemDecimal (Long ItemHandle)
Syntax 2: GetItemDecimal (long ParentItemHandle, string
szKey)
Syntax 3: GetItemDecimal (string szPath)
Syntax 1
Description
Gets the value of the item whose type is decimal.
Applies to
Syntax
|
1 |
objectname.GetItemDecimal (Long ItemHandle) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the JSONParser object whose item value you |
|
ItemHandle |
A long whose value is the handle of the item of |
Return value
Decimal.
Returns the decimal value of the item if it succeeds; if any
argument’s value is null, returns null; if an error occurs, 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 decimal value of the first item:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
JsonParser lnv_JsonParser String ls_Json Long ll_RootObject, ll_item Decimal ld_MessageID lnv_JsonParser = Create JsonParser ls_Json = '{"MessageID": 3.14159265357, "parm":"test"}' lnv_JsonParser.LoadString(ls_Json) ll_RootObject = lnv_JsonParser.GetRootItem() ll_item = lnv_JsonParser.GetChildItem(ll_RootObject, 1) ld_MessageID = lnv_JsonParser.GetItemDecimal(ll_item) |
Syntax 2
Description
Gets the value of the item whose type is decimal.
Applies to
Syntax
|
1 |
objectname.GetItemDecimal (long ParentItemHandle, string szKey) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the JSONParser object whose child item value |
|
ParentItemHandle |
A long whose value is the handle of the parent item of |
|
szKey |
A string whose value is the key of the child item of |
Return value
Decimal.
Returns the decimal value of the child item if it succeeds; if any
argument’s value is null, returns null; if an error occurs, 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 value of the “MessageID” item:
|
1 2 3 4 5 6 7 8 9 10 11 |
JsonParser lnv_JsonParser String ls_Json Long ll_RootObject Decimal ld_MessageID lnv_JsonParser = Create JsonParser ls_Json = '{"MessageID": 3.14159265357, "parm":"test"}' lnv_JsonParser.LoadString(ls_Json) ll_RootObject = lnv_JsonParser.GetRootItem() ld_MessageID = lnv_JsonParser. GetItemDecimal (ll_RootObject, "MessageID") |
Syntax 3
Description
Gets the value of the item whose type is decimal.
Applies to
Syntax
|
1 |
objectname.GetItemDecimal (string szPath) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the JSONParser object whose item value you |
|
szPath |
A string whose value is the path of the item of |
Return value
Decimal.
Returns the decimal value of the item if it succeeds; if any
argument’s value is null, returns null; if an error occurs, 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 value of the first item according to its
item path:
|
1 2 3 4 5 6 7 8 9 10 |
JsonParser lnv_JsonParser String ls_Json, ls_Path Decimal ld_MessageID lnv_JsonParser = Create JsonParser ls_Json = '{"MessageID": 3.14159265357, "parm":"test"}' lnv_JsonParser.LoadString(ls_Json) ls_Path = "/MessageID" ld_MessageID = lnv_JsonParser.GetItemDecimal(ls_Path) |
See also