Page History
...
Syntax
Code Block |
---|
Result = SRP_JSONJson(Handle, "REMOVERemove", Identifier) |
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 find. Required. |
Remarks
The REMOVE Remove service removes a child 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, then the identifier should be a member name. For example, you would pass "FirstName" to remove a member whose name is "FirstName". If the entity is a JSON array, then identifier should be an element index. For example, you would pass "10" to remove the tenth element. Note that removing an element from an array doesn't actually change the size of the array. Rather, the element at the given index is set to null.
Example
Code Block |
---|
// Create a JSON array, add elements to it, then remove one If SRP_JSONJson(ArrayHandle, "NEWNew", "ARRAY") then SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", "12345") SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", 67890, "NUMBER") SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", 1, "BOOLEAN") Result = SRP_JSONJson(ArrayHandle, "REMOVERemove", 2) ; // Sets element 2 to null SRP_JSONJson(ArrayHandle, "RELEASERelease") end // Create a JSON object, add members to it, then remove one If SRP_JSONJson(ObjectHandle, "NEWNew", "OBJECT") then SRP_JSONJson(ObjectHandle, "SETVALUESetValue", "name", "John Doe") SRP_JSONJson(ObjectHandle, "SETVALUESetValue", "city", "Washington D.C.") Result = SRP_JSONJson(ObjectHandle, "REMOVERemove", "city") ; // removes "city" member SRP_JSONJson(ObjectHandle, "RELEASERelease") end |