AddJSONElement()
Syntax
Result = AddJSONElement(JSONValue [, Index])Description
Add a new array element to a JSON value of type #PB_JSON_Array.
Parameters
JSONValue The JSON value. The value must be of type #PB_JSON_Array. Index (optional) The index at which the new value will be inserted into the array. If the index is outside of the range of the array, the new value will be inserted either at the start (for Index < 0) or the end of the array. If this parameter is not specified, the new value is added at the end of the array.
Return value
Returns the address of the added JSON value. The newly added value initially has type #PB_JSON_Null.
Example
If CreateJSON(0) ArrayValue = SetJSONArray(JSONValue(0)) ; add element at the end For i = 1 To 5 NumValue = AddJSONElement(ArrayValue) SetJSONInteger(NumValue, i) Next i ; insert at a specific index StrValue = AddJSONElement(ArrayValue, 1) SetJSONString(StrValue, "Hello") Debug ComposeJSON(0) EndIf
See Also
SetJSONArray(), RemoveJSONElement(), ResizeJSONElements(), ClearJSONElements(), GetJSONElement(), JSONArraySize(), JSONType()
Supported OS
All