java - jackson2 - unexpected field in JSON -


i'm trying write json java object. works fine until write values string using objectmapper. string shows unexpected field in json document called "map".

i want this:

{   "name": [     {         "a": "1",         "b": "2",         "c": "3",         "d": "4",         "e": "5",         "f": "6"     }   ] } 

i this:

 {   "name": [     {       "map": {         "a": "1",         "b": "2",         "c": "3",         "d": "4",         "e": "5",         "f": "6"       }   ] } 

this class i've defined object want convert json:

public class someclass{     private list<jsonobject> name;  //getters, setters } 

can me?

please notice inside class serializing have parameter called map if called bla have seen:

{   "name": [ {   "bla": {     "a": "1",     "b": "2",     "c": "3",     "d": "4",     "e": "5",     "f": "6"   }  ] } 

in order rid of parameter name should use annotation: @jsonunwrapped on top of map parameter inside class, like:

@jsonunwrapped private map<string, string> map; 

another option create getter function map use following:

objectmapper mapper = new objectmapper(); return mapper.writevalueasstring(map.getdatamap()); 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -