java - Gson Expected a name but was BEGIN_OBJECT at line 1 column 492 -


i having issue when converting array json object. exception is: expected name begin_object @ line 1 column 492

i searched forum cases found, none helped solve issue.

this checklist going parsed: http://pastebin.com/9kyk6hmu

this json same 1 generated through gson object itself, put both in winmerge check if there wrong , there wasn't.

this how doing conversion json:

    gsonbuilder builder = new gsonbuilder();     builder.registertypeadapterfactory(new checklistitemconverteradapterfactory());                    gson convert = builder.excludefieldswithoutexposeannotation().create();     return convert.tojson(actvchecklist); 

and convert checklist object:

    gsonbuilder builder = new gsonbuilder();     builder.registertypeadapterfactory(new checklistitemconverteradapterfactory());                   gson convert = builder.excludefieldswithoutexposeannotation().create();     checklist answeredchecklist = convert.fromjson(checklistanswer, checklist.class); 

the full stack here: http://pastebin.com/vhlgg0mv

is there further configuration should done in order conversion work properly?

this converter curstom adapter factory:

public class checklistitemconverteradapterfactory implements typeadapterfactory {  @override public <t> typeadapter<t> create(final gson gson, typetoken<t> type) {     class<? super t> rawtype = type.getrawtype();     if (rawtype == checklistitemfiletype.class) {         return new checklistitemfiletypeadapter<>();     }     return null; }  public class checklistitemfiletypeadapter<t> extends typeadapter<t> {     @override     public void write(jsonwriter out, t value) throws ioexception {         if (value == null) {             out.nullvalue();             return;         }         checklistitemfiletype filetype = (checklistitemfiletype) value;         // here write want jsonwriter.         out.beginobject();         out.name("value");         out.value(filetype.name());         out.name("pattern");         out.value(filetype.getpattern());         out.endobject();     }      @override     public t read(jsonreader in) throws ioexception {         return null;     } } 


Comments