1.依赖
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.21</version>
</dependency>
2.代码
import cn.hutool.json.JSONUtil;
import java.util.List;
/**
* 字符串类型的JSON数组转List<Object>
*/
public class StrJsonArrayToListObject {
public static void main(String[] args) {
String strJsonArray = "[\n" +
" {\n" +
" \"_object_version\": 4,\n" +
" \"updateAuthorizers\": [\n" +
" ],\n" +
" \"RELATED_POOL\": \"网络云-大区金华可信11\",\n" +
" \"CLOUD\": \"大区网络云\",\n" +
" \"modifier\": \"easyops\",\n" +
" \n" +
" },\n" +
" {\n" +
" \"_object_version\": 4,\n" +
" \"updateAuthorizers\": [\n" +
" ],\n" +
" \"RELATED_POOL\": \"网络云-大区金华可信11\",\n" +
" \"CLOUD\": \"大区网络云\",\n" +
" \"modifier\": \"easyops\",\n" +
" \n" +
" },\n" +
" {\n" +
" \"_object_version\": 4,\n" +
" \"updateAuthorizers\": [\n" +
" ],\n" +
" \"RELATED_POOL\": \"网络云-大区金华可信11\",\n" +
" \"CLOUD\": \"大区网络云\",\n" +
" \"modifier\": \"easyops\",\n" +
"\n" +
" }\n" +
"]";
List<Object> list = JSONUtil.parseArray(strJsonArray);
for (Object o : list) {
System.out.println(o);
}
}
}
3.JSON数组
[
{
"_object_version": 4,
"updateAuthorizers": [
],
"RELATED_POOL": "网络云-大区金华可信11",
"CLOUD": "大区网络云",
"modifier": "easyops",
},
{
"_object_version": 4,
"updateAuthorizers": [
],
"RELATED_POOL": "网络云-大区金华可信11",
"CLOUD": "大区网络云",
"modifier": "easyops",
},
{
"_object_version": 4,
"updateAuthorizers": [
],
"RELATED_POOL": "网络云-大区金华可信11",
"CLOUD": "大区网络云",
"modifier": "easyops",}
]
4.运行结果