java - ObjectMapper writeValueAsString() method convert field name into lowercase -
i have entity named data
class info { string name; int age; // constructor & getters & setters }
when utilize objectmapper
data objdata = new data("xyz",3); objectmapper mapper = new objectmapper(); system.out.println(mapper.writevalueasstring(objdata));
output :
{"name":"xyz","age":3}
it convert field name lower case.
how can output
{"name":"xyz","age":3}
why not utilize @jsonproperty? here's how.
@jsonproperty("name") public string getname(){ homecoming name; } @jsonproperty("age") public int getage() { homecoming age; }
java json jackson
No comments:
Post a Comment