How to parse json with java language keywords -


is there away parse json java keywords class, case, default etc. java object using gson library? lines

gson gson = new gson(); myobject myobject = gson.fromjson(json, myobject.class); 

simply parse json pojo, have key "class" in json , can't use field "class" in java classes.

yes, annotate fields @serializedname, specifying name of field.

@serializedname("class") private string classfield; 

or use custom typeadapter.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -