JSON to JAVA POJO of dynamic key-value pair -
i have create pojo class of following json, problem key p_d has variables dynamic name s_t, n_t, n_p , etc. real json big , facing problem part only, shared partial json. using jackson parsing.
{ "flag": true, "flag2": false, "r_no": [ { "room_type": 250067, "no_of_rooms": 1, "no_of_children": 1, "no_of_adults": 2, "description": "executive room, 1 king bed, non smoking", "children_ages": [ 8 ] }, { "room_type": 250067, "no_of_rooms": 1, "no_of_children": 0, "no_of_adults": 2, "description": "executive room, 1 king bed, non smoking" } ], "r_code": "abc", "r_key": "123", "p_d": { "s_t": [ { "name": "xyz", "cur": "inr" }, { "name": "xyz1", "cur": "inr" } ], "n_t": [ { "name": "xyz2", "cur": "inr" } ], "n_p": [ { "name": "xyz5", "cur": "inr" } ] }, "cur": "inr" }
for dynamic keys, use map<string, object>
:
objectmapper mapper = new objectmapper(); map<string, object> parsed = mapper.readvalue(json, new typereference<map<string, object>>() {});
Comments
Post a Comment