java - Deserializing a field named "class" into a POJO using Jackson -
this may dumb question, deserialize json object pojo myobject
field named class
, reserved keyword in java... if possible, i'd keep myobject
jackson/json/whatever-dependency free.
do need add (standard or jackson-specific) java annotation class field member handle this? or there work-around have "pure" java object? can configure jackson object mapper if needed.
public class myobject { public string field1; public string class; // fail }
since class
reserved java keyword, cannot use directly. if want generated json have it, use @jsonproperty
, set value
attribute.
public class myobject { public string field1; @jsonproperty(value = "class") public string clazz; }
Comments
Post a Comment