This is the json encoding my php echos:
{"detail1":{"key1":"value1","key2":"value2","key3":"value3"},"detail2":["elementone","elementtwo","elementthree"],"detail3":["element1","element2","element3"]}
The gson commands i use in the application are:
Gson gson = new Gson();
ParseActivity.parsedata = gson.fromJson(result, new TypeToken < HashMap < String , Object>>(){}.getType());
But gson is giving a jsonparseexception and is not able to parse, parsedata is a static variable of the same type.
Thanks for any help
You need to be more explicit in the returned type. The field
detail1is aMap<String, String>and other fields areList<String>. You need to create a wrapper class (a Javabean) with exactly those fields:so that you can use it as follows:
Alternatively, you can let Gson convert it to a
JsonElementtree so that you can traverse it manually: