Page History
...
Syntax
Code Block |
---|
Result = SRP_JSONJson(Handle, "GETCOUNTGetCount") |
Returns
Returns the number of members in a JSON object or elements in a JSON array.
Parameters
Parameter | Description |
---|---|
Handle | Handle to a JSON Entity. Required. |
Remarks
The GETCOUNT GetCount service returns the number of children within the given JSON Entity. If it is a JSON object, then it counts the number of members. If it is a JSON array, then it counts the number of elements. If there are no children, or if the handle points to a String, Number, or Boolean type entity, then the result will be 0.
Example
Code Block |
---|
// Create a JSON array, add elements to it, and get the count If SRP_JSONJson(ArrayHandle, "NEWNew", "ARRAY") then SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", "12345") SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", 67890, "NUMBER") SRP_JSONJson(ArrayHandle, "ADDVALUEAddValue", 1, "BOOLEAN") Count = SRP_JSONJson(ArrayHandle, "GETCOUNTGetCount") ; // Returns 3 SRP_JSONJson(ArrayHandle, "RELEASERelease") end // Create a JSON object, add members to it, and get the count If SRP_JSONJson(ObjectHandle, "NEWNew", "OBJECT") then SRP_JSONJson(ObjectHandle, "SETVALUESetValue", "name", "John Doe") SRP_JSONJson(ObjectHandle, "SETVALUESetValue", "city", "Washington D.C.") Count = SRP_JSONJson(ObjectHandle, "GETCOUNTGetCount") ; // Returns 2 SRP_JSONJson(ObjectHandle, "RELEASERelease") end |