Monday, 15 September 2014

json - java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 for JSONString to ArrayList conversion -



json - java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 for JSONString to ArrayList<String> conversion -

i trying convert next json string arraylist using gson.

[{type=email, currentstatus=draft, id=55, createdat=1408339109, createdby=9, depth=minimal, folderid=409, name=first email, permissions=fullcontrol, updatedat=1408339787, updatedby=9, htmlcontent={type=structuredhtmlcontent}}, {type=email, currentstatus=draft, id=56, createdat=1408365174, createdby=9, depth=minimal, folderid=42, name=untitled email, permissions=fullcontrol, updatedat=1408365174, updatedby=9, htmlcontent={type=structuredhtmlcontent}}, {type=email, currentstatus=draft, id=57, createdat=1408369734, createdby=9, depth=minimal, folderid=42, name=new email, permissions=fullcontrol, updatedat=1408369734, updatedby=9, htmlcontent={type=structuredhtmlcontent}}]

i doing below

gson gson = new gson(); type type = new typetoken<list<email>>(){}.gettype(); list<email> elist = gson.fromjson(response.body, type ); // code fails here ( email email : elist){ // next steps. }

please help prepare it. in advance.

java json arraylist gson

No comments:

Post a Comment