+-
Java Spring Boot: 创建数组列表
  String jsonResponse = "[{
      "employee": {
        "name": [
          "Mike"
        ],
        "id": [
          "181"
        ]
      }
    }, {
      "employee": {
        "name": [
          "Smith"
        ],
        "id": [
          "204"
        ]
      }
    }]";

   JSONObject result = new JSONObject(jsonResponse);

MultiMap multiMap = new MultiValueMap();

result.forEach(res -> {
  multiMap.put("name", ((JSONObject) 
res).getJSONObject("_source").getJSONArray("name").toString());
  multiMap.put("id", ((JSONObject) 
res).getJSONObject("_source").getJSONArray("id").toString());
  });

我有上述数据。我需要如下的响应。

[{
        "name": [
            "Mike"
        ],
        "id": [
            "181"
        ]
    },
    {
        "name": [
            "Smith"
        ],
        "id": [
            "204"
        ]
    }
]

有不同的方法来实现它。

可能是通过Hash表或数组列表。

我也遵循了 https:/www.baeldung.comjava-multi-dimensional-arraylist