lundi 2 mars 2015

How to process JSON in Java



I have a .JSON file that has content as:



"Name":"something"
"A":10
"B": 12

"Name":"something else"
"A":5
"B":9
....


I want to read this file and then find among these objects which one have the most number of parts(sum of A+B). What would be a good approach to that? I thought about reading JSON data in a Map, and then going through each object of the Map, finding the its total number of A+B, and then storing that in another linked list as LinkedList<String,Integer> (where String would be a name, and Integer would be the sum of A+B). Then after that sort LinkedList, and then findout which ever has the most number of A+B. Would this be a good solution?




Aucun commentaire:

Enregistrer un commentaire