Java 无效的JSON列表<;地图<;字符串,字符串>&燃气轮机;在爪哇

Java 无效的JSON列表<;地图<;字符串,字符串>&燃气轮机;在爪哇,java,json,list,Java,Json,List,我在JAVA中有:私人地图车 然后,另一个类映射将被转换为如下所示的映射列表 List<Map<String,String>> car; and then here is the implementation List<Map<String, String>> mylist = new ArrayList<>(); CarEvidence.getCarFieldsEvidence().forEach((key, value)

我在JAVA中有:
私人地图车

然后,另一个类映射将被转换为如下所示的映射列表

List<Map<String,String>> car;

 and then here is the implementation

 List<Map<String, String>> mylist = new ArrayList<>();
 CarEvidence.getCarFieldsEvidence().forEach((key, value) -> {
            mylist.add(new HashMap<String,String>(){{
                put("field",key);
                put("value",value);
            }});
        });
但是如果我发送这个,服务返回200 ok

"mylist": 
        {
          "field": "firstValue",
          "secondValue": null,
          "value": ""
        }

请提供帮助:(

下面给出了
列表
对应的JSON

[
            {
              "field": "unique",
              "secondValue": "pontiac",
              "value": "10000"
            },
            {
              "field": "other",
              "secondValue": null,
              "value": "any value"
            },
            {
              "field": "log",
              "secondValue": null,
              "value": "contract"
            },
            {
              "field": "message",
              "secondValue": null,
              "value": "last value"
            }
          ]
当您发送时,它发送200的原因

"mylist": 
        {
          "field": "firstValue",
          "secondValue": null,
          "value": ""
        }

因为,映射中的键被视为“mylist”,值作为json的字符串

json总是以
{
开头,以
}结尾
…这意味着,您必须将
myList
设置为某个对象的属性,然后对其进行正确编码。添加花括号,您将看到它将进行解析:

显然,端点并不期望
myList
是一个列表,而是一个单独的对象。在这方面使用
HashMap
完全没有意义情况;只需使用
ArrayList
"mylist": 
        {
          "field": "firstValue",
          "secondValue": null,
          "value": ""
        }