【发布时间】:2013-08-13 16:25:01
【问题描述】:
我正在尝试通过杰克逊将以下 json 映射到 pojo。我有第一部分工作(直到部分)。但是,第二部分我不确定如何将“section1”映射到可能包含的 pojo 或最佳实践?
通过休息调用收到的json:
{
"val1":100,
"val2":2.75,
"junk":[
{
"junk1":36,
"junk2":78
},
{
"junk1":36,
"junk2":78
}
],
"section1":{ // <- There will be another section2, section3,...
"val1":100,
"val2":2.75,
"junk1":[
{
"junk1":36,
"junk2":78
},
{
"junk1":36,
"junk2":78
}
],
"junk2":[
{
"junk1":36,
"junk2":78
},
{
"junk1":36,
"junk2":78
}
]
}
}
波乔:
public class view
{
private int val1;
private float val2;
private List<Map<String, String> > junk; //<-Ok as I just pass to another class
// How to store "section" ... and want to keep junk1, junk2 same
// placeholder like I have for junk in main section above.
}
【问题讨论】:
-
您的 JSON 不会生成 gud 对象...您对节号或垃圾号有限制吗?
标签: json spring-mvc jackson