Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

...

Code Block
 // 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")

 end

See Also

ADD