Removes all members from a JSON obect or all elements from a JSON array.
Syntax
Result = SRP_Json(Handle, "RemoveAll")
Returns
Returns 1 if successful, 0 if not.
Parameters
Parameter | Description |
---|---|
Handle | Handle to a JSON Entity. Required. |
Remarks
The RemoveAll service removes all children 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, all named members are removed. If the entity is a JSON array, then all elements are removed and the array size is 0.
Example
// 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