java - Json to HashMap -


i have following json output, how convert hashmap using gson:

{     "result": {         "haystack": [             "svqfd",             "ucr3y",             "azvb0",             "drdql",             "gc8lq",             "jqkdk",             "9ze4g",             "820gw",             "ekwkr",             "qgdrr",             "enpyz",             "lf4b8",             "szsut",             "yo0cq",             "cd1o0",             "rvw8t",             "eusc0",             "3oemt",             "6bugc",             "m8pfk"         ],         "needle": "lf4b8"     } } 

i tried:

type stringarraymap = new typetoken<map<string, string[]>>(){}.gettype();  map<string,string[]> thecollection = gson.fromjson(output, stringarraymap); 

edit: each time json output,its content unique same structure.

answer

answers , suggestions below worked played around , figured else worked well;

type stringstringobjectmap = new typetoken<map<string, map<string, object>>>(){}.gettype();  map<string, map<string, object>> thedictionary = gson.fromjson(output, stringstringobjectmap);  

1.) parse json string create jsonobject.

2.) iterate on jsonobject create map.

you might here want


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -