JSON_ArraySetValue

JSON_ArraySetValue

%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

handle

Handle to parent JSON array.

index

Index

value

New 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.

 

If the array is shared, the handle gets a private copy of the array and the change is not visible in the parent object or array. See Sharing of arrays.

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)