json对象字符串,公认, 是对应Map<String, Object>

json数组字符串,也是公认的,对应List<Map<String, Object>>或者List<String>

 

这边的Object可以是string, 数字,对象,或者数组

 

如果是json数组字符串:

 

[
    {
        "vendorId":1,
        "checkList":[
            {
                "imageId":1,
                "algorithmType":"person",
                "maxCapacity":50,
                "deviceIds":"xxxx,yyyy"
            }
        ]
    }
]

 

java:

 

测试代码:

String test = "[{\"vendorId\":1, \"checkList\":[{\"imageId\":1,\"algorithmType\":\"person\", \"maxCapacity\":50, \"deviceIds\":\"xxxx,yyyy\"}]}]";
//如果是字符串对象,可以强转成Map<String, Object>
List<Map<String, Object>> vendors = (List<Map<String, Object>>) JSON.parse(test);
//获取第一个对象
Map<String, Object> vendor = vendors.get(0);
//如果是对象,可以强转成Map<String, Object>
List<Map<String, Object>> images = (List<Map<String, Object>>) vendor.get("checkList");
Map<String, Object> image = images.get(0);
System.out.println(JSON.toJSONString(image));

JSONObject和JSONArray , 都有实现Map,  List相关的接口,可以直接强转。