我有 4 个 POJO
我有一个类文件将根据这些 POJO 映射值
当我运行代码时
public static void main(String[] args) throws Exception {
Input user = new Input();
user.setId("0001");
user.setType("donut");
user.setName("cake");
user.setPpu(0.55);
下面是我的输出
{
"id" : "0001",
"type" : "donut",
"name" : "cake",
"ppu" : 0.55,
"batters" : null,
"topping" : [ ]
}
但是,我希望我的输出是
{ "id": "0001", "type": "donut", "name": "Cake", "ppu": 0.55, "batters":
{ "batter": [{ "id": "1001", "type": "Regular" },
{ "id": "1004", "type": "Devil's Food" } ] }, "topping": [{ "id": "5001",
"type": "None" }, { "id": "5004", "type": "Maple" } ] }
我不确定如何即兴编写代码以像我期望的那样打印输出,谢谢
萧十郎
慕码人8056858
相关分类