Page History
...
The SETVALUE service sets a child within a given JSON Entity. This service only works on JSON objects and JSON arrays. If it is a JSON object, then Identifier needs to be a member name, such as "id" or "first-name". If it is a JSON array, then identifier needs to be an index, such as 1 or 10. Unlike SET, you do not pass another JSON Entity Handle. Instead, you pass a value via the NewValue parameter. When you pass the value without 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.
...
Code Block |
---|
// Create a JSON array, add elements to it, and get the count If SRP_JSON(ArrayHandle, "NEW", "ARRAY") then SRP_JSON(ArrayHandle, "SETVALUE", 1, "12345") SRP_JSON(ArrayHandle, "SETVALUE", 10, 67890, "NUMBER") SRP_JSON(ArrayHandle, "SETVALUE", 5, 1, "BOOLEAN") SRP_JSON(ArrayHandle, "RELEASE") end // Create a JSON object, add members to it, and get the count If SRP_JSON(ObjectHandle, "NEW", "OBJECT") then SRP_JSON(ObjectHandle, "SETVALUE", "name", "John Doe") SRP_JSON(ObjectHandle, "SETVALUE", "city", "Washington D.C.") SRP_JSON(ObjectHandle, "SETVALUE", "zip", "12345", "NUMBER") SRP_JSON(ObjectHandle, "RELEASE") SRP_JSON(ObjectHandle, "RELEASE") end |