Sorts an object's members by member name.
Syntax
SRP_JsonX_Sort(Path, Recursive)
Returns
1 if successful, 0 if there was an error.
Parameters
| Parameter | Description |
|---|---|
| Path | Path to an object whose elements to sort. |
| Recursive | 1 to also sort all child objects, 0 to sort only the given one. Optional. Default is 0. |
Remarks
SRP_JsonX_Sort sorts all members of the object pointed to by Path by member name. See Paths for more details. The sort is always done A-Z and is case sensitive. If you set Recursive to 1, then the routine will also sort the members of all objects below this one in the hierarchy.
Examples
$insert SRPJSONX
Json = '{'
Json := ' "employees": ['
Json := ' {'
Json := ' "firstname": "John",'
Json := ' "lastname": "Doe",'
Json := ' "age": 21'
Json := ' },'
Json := ' {'
Json := ' "firstname": "Anna",'
Json := ' "lastname": "Smith",'
Json := ' "age": 32'
Json := ' },'
Json := ' {'
Json := ' "firstname": "Peter",'
Json := ' "lastname": "Jones",'
Json := ' "age": 43'
Json := ' }'
Json := ' ],'
Json := ' "nums": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],'
Json := ' "active": true,'
Json := ' "alwaysnull": null,'
Json := ' "alwaysstring": "4.321"'
Json := '}'
SRP_JsonX_Parse('MyDocument', json)
SRP_JsonX_Sort('', JsonxRecursive$)
NewJson = SRP_JsonX_End('Pretty')