spring mvc - Java - Mapping dynamic JSON to DTO -


i have problem map json data dto's following payload

"wigdata": {         "wig": {             "0": {                 "parentwig": "",                 "wigname": "testing wig 1",                 "wigstart": "01/08/2017",                 "wigfromx": "1",                 "wigtoy": "123",                 "wigend": "31/08/2017",                 "wigachievementtype": "number"             },             "1": {                 "parentwig": "",                 "wigname": "testing wig 2",                 "wigstart": "01/08/2017",                 "wigfromx": "1",                 "wigtoy": "123",                 "wigend": "31/08/2017",                 "wigachievementtype": "number"             }         }     } 

the dto's failed map wig's payload since serialize data jquery json serializable

i have created dto payload this,

class wigdata {     private wigs wigs; // setter getter }  class wigs {     private list<wig> index; // setter getter }  class wig {     private string parentwig;     private string wigname;     private date wigstart;     private date wigfromx;     private bigdecimal wigtoy;     private string wigachievementtype; // setter getter } 

this output dto

wigdata: {   wigs: null } 

but no luck, can please fix this?

since not possible change payload

check more on json array.

try using below:

"wigdata": {     "wig": [{             "parentwig": "",             "wigname": "testing wig 1",             "wigstart": "01/08/2017",             "wigfromx": "1",             "wigtoy": "123",             "wigend": "31/08/2017",             "wigachievementtype": "number"         }, {             "parentwig": "",             "wigname": "testing wig 2",             "wigstart": "01/08/2017",             "wigfromx": "1",             "wigtoy": "123",             "wigend": "31/08/2017",             "wigachievementtype": "number"         }     ] }  class wigdata {     private list<wig> wig;     // setter getter }  class wig {     private string parentwig;     private string wigname;     private date wigstart;     private date wigfromx;     private bigdecimal wigtoy;     private string wigachievementtype; // setter getter } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -