Removes a member from a JSON object or an element from a JSON array.


Result = SRP_Json(Handle, "Remove", Identifier)


Returns 1 if successful, 0 if not.


HandleHandle to a JSON Entity. Required.
IdentifierThe object member or array element to find. Required.


The 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.


// Create a JSON array, add elements to it, then remove one
If SRP_Json(ArrayHandle, "New", "Array") then
   SRP_Json(ArrayHandle, "AddValue", "12345")
   SRP_Json(ArrayHandle, "AddValue", 67890, "Number")
   SRP_Json(ArrayHandle, "AddValue", 1, "Boolean")
   Result = SRP_Json(ArrayHandle, "Remove", 2)       ; // Sets element 2 to null
   SRP_Json(ArrayHandle, "Release")

// Create a JSON object, add members to it, then remove one
If SRP_Json(ObjectHandle, "New", "Object") then
   SRP_Json(ObjectHandle, "SetValue", "name", "John Doe")
   SRP_Json(ObjectHandle, "SetValue", "city", "Washington D.C.")
   Result = SRP_Json(ObjectHandle, "Remove", "city") ; // removes "city" member
   SRP_Json(ObjectHandle, "Release")

See Also


  • No labels