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
Post a Comment