Adds a value to a JSON array.


Result = SRP_Json(Handle, "AddValue", NewValue, Type)


Returns 1 if successful, 0 if not.


HandleHandle to JSON Entity. Required.
NewValueNew value to be added to the JSON array. Required.
TypeThe value's type: String, Number, or Boolean. Optional.


The AddValue service adds the given value (String, Number, Boolean, or Null) to the end of the array. This only works if Handle is a JSON array. Unlike the Add service, you do not pass a handle to another JSON entity. This method is also more convenient and a little faster than Add. When you pass the value without specifying its type, then its type is automatically determined from the value itself. Empty values become Null types and values detected to be a number become the Number type. Everything else becomes a string. You can always force the type you want by setting the Type parameter explicitly.


 // Create a JSON array (which initializes ArrayHandle)
If SRP_Json(ArrayHandle, "New", "Array") then

   // This will be added as a String (even though the value contains only numbers)
   SRP_Json(ArrayHandle, "AddValue", "12345")

   // Now add an actual number value to the array
   SRP_Json(ArrayHandle, "AddValue", 67890, "Number")

   // Add a boolean
   SRP_Json(ArrayHandle, "AddValue", 1, "Boolean")

   // Remember to release entities you've created
   SRP_Json(ArrayHandle, "Release")


See Also


  • No labels