Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How to sort json object?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


venkatesh
How to sort json object?
0 Answer(s)      4 years ago
Posted in : Java Beginners


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


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com