-1

How to parse object like this in android volley ? (or GSON ?) it is always a key, value. Keys are of course unknown, and length variable. I need to put it in hash map or Arraylist of simple objects

{ "9784": 0.1, "71707": 0.1, "116271": 0.1, "118908": 0.5, "119162": 0.1, "119163": 0.1, "119181": 0.1, "119182": 0.1, "119183": 0.1, "119184": 0.1 }

maxxxo
  • 672
  • 3
  • 10
  • 28
  • 1
    In the mentioned answer is explained how to parse JSON if you know what value names are coming. Issue here is that I am receiving always "key" : value and I do not know their both values, just that one is string, one double – maxxxo Jan 22 '14 at 08:28
  • How to parse the JSON is explained in http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android what are you trying to do is use the object created from the JSON. Have you tried looking how Java handles reflection? – Albireo Jan 22 '14 at 12:03

1 Answers1

0

Using GSON you can parse it into Map.

Type listType = new TypeToken<Map<String,Double>>(){}.getType();  
Map<String,Double> map= new Gson().fromJson(JSON_STRING, listType);
Asif Bhutto
  • 3,916
  • 1
  • 24
  • 21