%JSON_ArraySetValue function


Function

Replaces an item at a given index in the JSON array by value.

Declaration
%JSON_ArraySetValue(
    INT in handle, 
    INT in index,
    UNIVAL in value
 )
Parameters
handleHandle to parent JSON array.
indexIndex
valueNew value
Return value

None

Description

Function replaces an item at a given index in the JSON array by value. Supported types are BOOL, INT, REAL, TEXT and invalid value. If you want to insert TIME, you have to convert it to TEXT first.

Exception is thrown if handle to parent JSON array is invalid, new value have unsupported type or index is out of range.

Example
 INT _arr
 _arr := %JSON_CreateArray()
 
 %JSON_ArraySetLength(_arr, 5)

 %JSON_ArraySetValue(_arr, 1, "IPESOFT")
 %JSON_ArraySetValue(_arr, 2, 365)
 %JSON_ArraySetValue(_arr, 3, 1.234)
 %JSON_ArraySetValue(_arr, 4, @TRUE)
 %JSON_ArraySetValue(_arr, 5, U.uservariable)

 %JSON_FreeArrayHandle(_arr)
Napíšte komentár