Question How to sort json object properties?

dmuller

New Member
I have similar code to create a json....
def var js-out-par as JsonObject no-undo.
def var js-person-aux as JsonObject no-undo.
def var jsa-person-aux as JsonArray no-undo.

assign js-out-par = new JsonObject()
jsa-person-aux = new JsonArray().

for each ct_tt-person no-lock:

js-person-aux = new JsonObject().
js-person-aux:Add("codePerson",ct_tt-person.id-person).

if ct_tt-person.nm-person <> ""
then js-person-aux:Add("name",ct_tt-person.nm-person).

if ct_tt-person.dt-birthday <> ?
then js-person-aux:Add("birthday",ct_tt-person.dt-birthday).

jsa-person-aux:add(js-person-aux).
end.

js-out-par:add("persons", jsa-person-aux).
Giving a result similar that...
{
"persons": [
{
"codePerson": 99998,
"birthday": "1985-02-31",
"name": "TEST TEST"

},
{
"codePerson": 99999,
"birthday": "1990-02-30",
"name": "TESTE TESTE"

}
]
}
But, I need to sort the properties from Json to have a result like this....
{
"persons": [
{
"codePerson": 99998,
"name": "TEST TEST",
"birthday": "1985-02-31"

},
{
"codePerson": 99999,
"name": "TESTE TESTE",
"birthday": "1990-02-30"

}
]
}
How to sort json object properties?
 
Top