Page History
...
Syntax
Code Block |
---|
Result = SRP_JSONJson(Handle, "ADDVALUEAddValue", NewValue, Type) |
Returns
Returns 1 if successful, 0 if not.
Parameters
Parameter | Description |
---|---|
Handle | Handle to JSON Entity. Required. |
NewValue | New value to be added to the JSON array. Required. |
Type | The value's type: String, Number, or Boolean. Optional. |
Remarks
The ADDVALUE 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 ADDAdd service, you do not pass a handle to another JSON entity. This method is also more convenient and a little faster than ADDAdd. When you pass the value withoutwithout 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.
Example
Code Block |
---|
// Create a JSON array (which initializes ArrayHandle) If SRP_JSONJson(ArrayHandle, "NEWNew", "ARRAY") then // This will be added as a String (even though the value contains only numbers) SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", "12345") // Now add an actual number value to the array SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", 67890, "NUMBER") // Add a boolean SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", 1, "BOOLEAN") // Remember to release entities you've created SRP_JSONJson(ArrayHandle, "RELEASERelease") end |