java - How can I convert JSON to a HashMap using Gson? -


i'm requesting data server returns data in json format. casting hashmap json when making request wasn't hard @ other way seems little tricky. json response looks this:

{      "header" : {          "alerts" : [              {                 "alertid" : "2",                 "tsexpires" : null,                 "target" : "1",                 "text" : "woot",                 "type" : "1"             },             {                  "alertid" : "3",                 "tsexpires" : null,                 "target" : "1",                 "text" : "woot",                 "type" : "1"             }         ],         "session" : "0bc8d0835f93ac3ebbf11560b2c5be9a"     },     "result" : "4be26bc400d3c" } 

what way easiest access data? i'm using gson module.

here go

type type = new typetoken<map<string, string>>(){}.gettype(); map<string, string> mymap = gson.fromjson("{'k1':'apple','k2':'orange'}", type); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -