Page History
...
Syntax
Code Block |
---|
Result = SRP_JSONJson(Handle, "SETSet", Identifier, NewEntityHandle) |
Returns
Returns 1 if successful, 0 if not.
Parameters
Parameter | Description |
---|---|
Handle | Handle to a JSON Entity. Required. |
Identifier | The object member or array element to set. Required. |
NewEntityHandle | Handle to another JSON Entity. Optional. |
Remarks
The SET service Setservice 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. The NewEntityHandle parameter must be a different valid JSON Entity Handle. The entity associated with that handle will be placed into the specified member/element of the entity associated with the Handle parameter.
...
Even though you are putting one entity into another, you still must RELEASERelease the child handle when you no longer need it.
Example
Code Block |
---|
// Create a simple string entity If SRP_JSONJson(StringHandle, "NEWNew", "STRINGString", "Hello, World!") then // Create a JSON array, set elements in any order If SRP_JSONJson(ArrayHandle, "NEWNew", "ARRAYArray") then SRP_JSONJson(ArrayHandle, "SETSet", 1, StringHandle) SRP_JSONJson(ArrayHandle, "SETSet", 10, StringHandle) SRP_JSONJson(ArrayHandle, "SETSet", 5, StringHandle) SRP_JSONJson(ArrayHandle, "RELEASERelease") end // Create a JSON object, add members to it If SRP_JSONJson(ObjectHandle, "NEWNew", "OBJECTObject") then SRP_JSONJson(ObjectHandle, "SETSet", "first-member", StringHandle) SRP_JSONJson(ObjectHandle, "SETSet", "second-member", StringHandle) SRP_JSONJson(ObjectHandle, "RELEASERelease") end // Remember to release handles we created SRP_JSONJson(StringHandle, "RELEASERelease") end |