Returns the number of members in a JSON object or elements in a JSON array.
Syntax
Result = SRP_Json(Handle, "GetCount")
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 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
// Create a JSON array, add elements to it, and get the count If SRP_Json(ArrayHandle, "New", "Array") then SRP_Json(ArrayHandle, "AddValue", "12345") SRP_Json(ArrayHandle, "AddValue", 67890, "Number") SRP_Json(ArrayHandle, "AddValue", 1, "Boolean") Count = SRP_Json(ArrayHandle, "GetCount") ; // Returns 3 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.") Count = SRP_Json(ObjectHandle, "GetCount") ; // Returns 2 SRP_Json(ObjectHandle, "Release") end