java arraylist用法Fastjson 的快速入门
1. 依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.28</version>
</dependency>
2. 用法大全
(1)Object
// Object --> String
String JSONString(article);
System.out.println(articleString);
// String --> Object
Article articleObject=JSON.parseObject(articleString, Article.class);
System.out.println(articleObject);
(2)ArrayList
// ArrayList<Object> --> String
String JSONString(list);
String JSONString(list);
System.out.println(listString1);
System.out.println(listString2);
// String --> ArrayList\<Object>
ArrayList<Article>list1=JSONObject.parseObject(listString1, new TypeReference<ArrayList<Article>>() {});
ArrayList<Article>list2=JSONObject.parseObject(listString2, new TypeReference<ArrayList<Article>>() {});
System.out.println(list1.size());
System.out.println(list2.size());

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。