Versions Compared

Key

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

...

Even though you are putting one entity into another, you still must RELEASE the child handle when you no longer need it.

...

Code Block
// Create a simple string entity
If SRP_JSON(StringHandle, "NEW", "STRING", "Hello, World!") then

   // Create a JSON array, set elements in any order
   If SRP_JSON(ArrayHandle, "NEW", "ARRAY") then
       SRP_JSON(ArrayHandle, "SET", 1, StringHandle)
       SRP_JSON(ArrayHandle, "SET", 10, StringHandle)
       SRP_JSON(ArrayHandle, "SET", 5, StringHandle)
       SRP_JSON(ArrayHandle, "RELEASE")
   end
   
   // Create a JSON object, add members to it
   If SRP_JSON(ObjectHandle, "NEW", "OBJECT") then
       SRP_JSON(ObjectHandle, "SET", "first-member", StringHandle)
       SRP_JSON(ObjectHandle, "SET", "second-member", StringHandle)
       SRP_JSON(ObjectHandle, "RELEASE")
   end
   
   // Remember to release handles we created
   SRP_JSON(StringHandle, "RELEASE")
   
end

See Also

SETVALUEADDADDVALUE