Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
Result = SRP_Json(Handle, "GetMembers", Delimiter, Sort)

Returns

Returns a dynamic array containing all the object's member names.

...

ParameterDescription
HandleHandle to a JSON Entity. Required.
DelimiterThe delimiter to use between each member name. Optional.
SortedDetermines if the member names should be sorted. Optional.

Remarks

The GetMembers service returns a list of all member names within a JSON object. It does not return the members' values, only their names. If you need a member's value, then you can use the GetValue service.

This service only works if Handle is a JSON object. If it is not an object, the result will be "". Also, if the object has no members, the result will be "". The Delimiter parameter is optional. If you omit the parameter, then @FM is used. Delimiter must be a single character.

You can opt to have object members sorted in the output. By definition, JSON object members are unordered, and you should never expect a particular member to be in a particular position. However, for large objects, sorting members could be a nice convenience. Set "Sorted" to 1 to make it happen.

Example

Code Block
// Create a JSON object
If SRP_Json(ObjectHandle, "New", "Object") then
   
   // Add some members to it
   SRP_Json(ObjectHandle, "SetValue", "name", "John Doe")
   SRP_Json(ObjectHandle, "SetValue", "city", "Washington D.C.")
   
   // Get the list of members, delimited by ~
   Members = SRP_Json(ObjectHandle, "GetMembers", '~')

   // If you want an @FM delimited list, just omit the last parameter
   Members = SRP_Json(ObjectHandle, "GetMembers")

   // Remember to release entities you've created
   SRP_Json(ObjectHandle, "Release")
   
 end

...