Versions Compared

Key

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

...

Syntax

Code Block
Result = SRP_JSONJson(Handle, "REMOVEALLRemoveAll")

Returns

Returns 1 if successful, 0 if not.

Parameters

ParameterDescription
HandleHandle to a JSON Entity. Required.

Remarks

The REMOVEALL RemoveAll service removes all children from a JSON entity. This service only works on JSON objects and JSON arrays and will return 0 for entities of type String, Number, and Boolean. If the entity is a JSON object, all named members are removed. If the entity is a JSON array, then all elements are removed and the array size is 0.

Example

Code Block
// Create a JSON array
If SRP_JSONJson(ArrayHandle, "NEWNew", "ARRAY") then
   
   // Add elements to it
   SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", "12345")
   SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", 67890, "NUMBER")
   SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", 1, "BOOLEAN")
   
   // Get the count, which is currently 3
   Count = SRP_JSONJson(ObjectHandle, "GETCOUNTGetCount")
   
   // Delete everything and get the count again, which will be 0
   Result = SRP_JSONJson(ArrayHandle, "REMOVEALLRemoveAll")
   Count = SRP_JSONJson(ArrayHandle, "GETCOUNTGetCount")
   
   SRP_JSONJson(ArrayHandle, "RELEASERelease")
   
 end

// Create a JSON object
If SRP_JSONJson(ObjectHandle, "NEWNew", "OBJECT") then
   
   // Add members to it
   SRP_JSONJson(ObjectHandle, "SETVALUESetValue", "name", "John Doe")
   SRP_JSONJson(ObjectHandle, "SETVALUESetValue", "city", "Washington D.C.")
   
   // Get the count, which is currently 2
   Count = SRP_JSONJson(ObjectHandle, "GETCOUNTGetCount")
   
   // Delete everything and get the count again, which will be 0
   Result = SRP_JSONJson(ObjectHandle, "REMOVEALLRemoveAll")
   Count = SRP_JSONJson(ObjectHandle, "GETCOUNTGetCount")
   
   SRP_JSONJson(ObjectHandle, "RELEASERelease")
   
 end

See Also

REMOVERemove