java - @JsonRootName not work as I want -


this facilitydto

@jsonrootname("facility") @xmlaccessortype(xmlaccesstype.none) @xmltype(name = "facility", proporder = { "id", "name", "totalquantity" }) public class facilitydto implements serializable {  private static final long serialversionuid = 1l;  @xmlelement(required = true) private string id; @xmlelement(required = true) private string name; @xmlelement(required = true) private double totalquantity;  public facilitydto() { }  public facilitydto(facility facility) {     this.name = facility.getname();     this.totalquantity = facility.gettotalquantity();     this.id = facility.getid(); }// getters setter 

this message body writer

bytearrayoutputstream out = new bytearrayoutputstream(); objectmapper mapper = new objectmapper(); mapper.registermodule(new jdk7module()); mapper.configure(serializationfeature.wrap_root_value, true); mapper.writevalue(out, object); int bytescount = out.size(); byte[] bytes = out.tobytearray(); entitystream.write(bytes); entitystream.flush(); 

the output of json format this enter image description here

my questions are:

  1. why results seem not correct? put @jsonrootname("facility") , enable wrap root feature.
  2. any part miss?

see jackson json deserialization root element

according above, need configure deserialization follows: mapper.configure(derializationfeature.unwrap_root_value, true);


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -