android - how to parse this json formate using Gson lib -
how parse sub array getstring("sub") using gson lib in android.
<pre> { "name" : "abc"; "class" : "xyz"; "address" : {[ "add" : "1"; "sub" :["abc"]; ]} } </pre>
first of should reduce json correct form:
{ "name" : "abc", "class" : "xyz", "address" : [ {"add" : "1", "sub" :["abc"]} ] }
now, create objects following structure:
class foo{ string name; string class; address[] address; } class address{ string add; string[] sub; }
and on step can parse json object, calling line:
foo foo = new gson().fromjson(json, foo.class);
Comments
Post a Comment