How to sort json object?

How to sort json object?

I've been looking for a while and want a way to sort a JSON object like this:

{"results": [ { "layerId": 5, "layerName": "Pharmaceutical Entities", "attributes": { "OBJECTID": "35", "FACILITYTYPE": "Pharmacy", "FACILITYSUBTYPE": "24 Hr Pharmacy", "COMMERCIALNAME_E": "SADD MAARAB PHARMACY", }, "geometryType": "esriGeometryPoint", }, { "layerId": 5, "layerName": "Pharmaceutical Entities", "attributes": { "OBJECTID": "1", "FACILITYTYPE": "Pharmacy", "FACILITYSUBTYPE": "24 Hr Pharmacy", "COMMERCIALNAME_E": "GAYATHY HOSPITAL PHARMACY",

},
"geometryType": "esriGeometryPoint",

}, { "layerId": 5, "layerName": "Pharmaceutical Entities", "attributes": { "OBJECTID": "255", "FACILITYTYPE": "Pharmacy", "FACILITYSUBTYPE": "24 Hr Pharmacy", "COMMERCIALNAME_E": "AL DEWAN PHARMACY", }, "geometryType": "esriGeometryPoint", } ]}

and sort is alphabetically by value of "COMMERCIALNAME_E" to get:

{"results": [ { "layerId": 5, "layerName": "Pharmaceutical Entities", "attributes": { "OBJECTID": "255", "FACILITYTYPE": "Pharmacy", "FACILITYSUBTYPE": "24 Hr Pharmacy", "COMMERCIALNAME_E": "AL DEWAN PHARMACY", }, "geometryType": "esriGeometryPoint", }, { "layerId": 5, "layerName": "Pharmaceutical Entities", "attributes": { "OBJECTID": "1", "FACILITYTYPE": "Pharmacy", "FACILITYSUBTYPE": "24 Hr Pharmacy", "COMMERCIALNAME_E": "GAYATHY HOSPITAL PHARMACY", }, "geometryType": "esriGeometryPoint", }, { "layerId": 5, "layerName": "Pharmaceutical Entities", "attributes": { "OBJECTID": "35", "FACILITYTYPE": "Pharmacy", "FACILITYSUBTYPE": "24 Hr Pharmacy", "COMMERCIALNAME_E": "SADD MAARAB PHARMACY", }, "geometryType": "esriGeometryPoint", } ]}

I can't find any code that will do this. Can anyone give me some help? Please give me any sample code to do solve this scenario.

Thanks, venkatesh

View Answers









Related Tutorials/Questions & Answers:
How to sort json object?
ModuleNotFoundError: No module named 'json-sort'
Advertisements
ModuleNotFoundError: No module named 'json-sort'
ModuleNotFoundError: No module named 'json-objects'
How to sort the rows in SQL?
How to sort chinese character in j2me?
How to sort ArrayList in java
retrieve JSON array objects in javascript
Sort
JSON array objects retrieval in javascript
Sort
how to sort the text file and display it in jtable
how to sort the elements of hashmap and to print output the key and the value attached to it
How to add dropdown list in a row of a sort table applet?
how to sort the result of this 2 class program in java.....????
how to sort multiple key columns in CSV file - Java Beginners
Creating Array Objects in JavaScript with JSON
insertion sort
bubble sort
How to Sort Column values of a jsp table - JSP-Servlet
What is JSON?
How to delete objects using Hibernate?
How do I sort by mutiple columns that are in ArrayList using some comparable class
ModuleNotFoundError: No module named 'sort'
Array sort
bubble sort
insertion sort
insertion sort
insertion sort
insertion sort
string array sort
string array sort
string array sort
string array sort
string array sort
Java insertion sort with string array
buble sort
com.tifosi-m - sort-tool version 1.0 Maven dependency. How to use sort-tool version 1.0 in pom.xml?
com.mahanaroad - mahana-topo-sort version 1.0.0 Maven dependency. How to use mahana-topo-sort version 1.0.0 in pom.xml?
sort function - JSP-Servlet
SEARCH AND SORT
How many objects are created in the code below? Explain.
quick sort
quick sort
quick sort
bubble sort - Java Beginners
php array sort by field
php array sort functions
php array sort by key
php array sort by value

Ads