Adds an array of values to a JSON array. New in 2.1.1

Syntax

Result = SRP_Json(Handle, "AddValueArray", Array, Delim)

Returns

Returns 1 if successful, 0 if not.

Parameters

ParameterDescription
HandleHandle to JSON Entity. Required.
ArrayArray of values to be added to the JSON array. Required.
DelimThe array's delimiter. Optional.

Remarks

The AddValueArray service adds the given array of values as a single array node to the end of the array. This only works if Handle is a JSON array. Normally, to add an array to the end of another array, you'd have to call AddValue repeatedly:

ValueArray = "1,2,3,4"
If SRP_Json(SubArrayHandle, "New", "Array") then
	For each Value in ValueArray using ","
		SRP_Json(SubArrayHandle, "AddValue", Value)
	Next Value
    SRP_Json(MainArrayHandle, "Add", SubArrayHandle)
    SRP_Json(SubArrayHandle, "Release")
end

This service does that work for you, simplifying the above code to this:

SRP_Json(MainArrayHandle, "AddValueArray", "1,2,3,4", ",")

The Delim parameter indicates the delimiter used to separate values in Array, which defaults to @FM if omitted.

Example

// Create an array, add a couple values, then add a sub-array
If SRP_Json(ArrayHandle, "New", "Array") then
   SRP_Json(ArrayHandle, "AddValue", "Hello, World!", "String")
   SRP_Json(ArrayHandle, "AddValue", 67890, "Number")
   SRP_Json(ArrayHandle, "AddValueArray", "1~2~3~4~5", "~")

   SRP_Json(ArrayHandle, "Release")
 end

See Also

AddValue

  • No labels