java - deserialization of a json array to a list and retaining the array order from json within list -


i have following json mapped pojo using jackson mapper. how retain order of array columns json during deserialization ? annotation should use ?

json:

{ "columnnames": [    "firstname",    "lastname",    "username" ], "values": [     [         "john",         "smith",         "jsmith"     ],     [         "tim",         "cook",         "tcook"     ] ] 

}

pojo:

public class data implements serializable {  private list<string> columnnames = new arraylist<string>();  private list<arraylist<string>> values = new arraylist<arraylist<string>>();  public list<string> getcolumnnames() {     return columnnames; }  public void setcolumnnames(list<string> columnnames) {     this.columnnames = columnnames; }  public list<arraylist<string>> getvalues() {     return values; }  public void setvalues(list<arraylist<string>> values) {     this.values = values; } 

}

  • expected getcolumnnames(): {"firstname","lastname","username"}
  • actual getcolumnnames(): {"username","firstname","lastname"}

i new jackson mapping appreciated.

jackson mapper fill arraylist maintaining order of json. if want different order can use annotation @jsonpropertyorder.

(http://fasterxml.github.io/jackson-annotations/javadoc/2.3.0/com/fasterxml/jackson/annotation/jsonpropertyorder.html)


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -