Versions Compared

Key

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

...

Code Block
// Create a JSON array
If SRP_JSON(ArrayHandle, "NEW", "ARRAY") then
   
   // Add elements to it
   SRP_JSON(ArrayHandle, "ADDVALUE", "12345")
   SRP_JSON(ArrayHandle, "ADDVALUE", 67890, "NUMBER")
   SRP_JSON(ArrayHandle, "ADDVALUE", 1, "BOOLEAN")
   
   // Get the count, which is currently 3
   Count = SRP_JSON(ObjectHandle, "GETCOUNT")
   
   // Delete everything and get the count again, which will be 0
   Result = SRP_JSON(ArrayHandle, "REMOVEALL")
   Count = SRP_JSON(ArrayHandle, "GETCOUNT")
   
   SRP_JSON(ArrayHandle, "RELEASE")
   
 end

// Create a JSON object
If SRP_JSON(ObjectHandle, "NEW", "OBJECT") then
   
   // Add members to it
   SRP_JSON(ObjectHandle, "SETVALUE", "name", "John Doe")
   SRP_JSON(ObjectHandle, "SETVALUE", "city", "Washington D.C.")
   
   // Get the count, which is currently 2
   Count = SRP_JSON(ObjectHandle, "GETCOUNT")
   
   // Delete everything and get the count again, which will be 0
   Result = SRP_JSON(ObjectHandle, "REMOVEALL")
   Count = SRP_JSON(ObjectHandle, "GETCOUNT")
   
   SRP_JSON(ObjectHandle, "RELEASE")
   
 end

See Also

REMOVE