<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.40</version>
</dependency>
import com.alibaba.fastjson.JSONObject;
public static void main(String[] args) {
User user = JSONObject.toJavaObject(jsonObject, User.class);
String s = "[1,10,20]";
JSONObject jSONObject = JSONObject.parseObject(s);
JSONObject s = "[1,10,20]";
String jsonString = JSONObject.toJSONString(s);
String s = "{"sites":[{"name":"test"},{"name":"test"}]}"
JSONObject jsonObject = JSONObject.parseObject(s);
JSONObject sites = jsonObject.getJSONArray("sites").getJSONObject(1);
String s = "[1,10,20]";
String[] parse = JSONObject.parseObject(s, String[].class);
String s = "[[22,23,23],[1,10,20]]";
String[][] parse = JSONObject.parseObject(s, String[][].class);
Integer[][] toStr= new Integer[][]{{1,2,3},{4,5,6}};
String s = JSONObject.toJSON(toStr).toString();
String s = "{\"name\":\"runoob\",\"alexa\":10000,\"sites\":[{\"site1\":\"www.runoob.com\",\"site2\":\"m.runoob.com\",\"site3\":\"c.runoob.com\"}]}";
JSONObject jsonObject = JSONObject.parseObject(s);
String name = jsonObject.getString("name");
Integer alexa = jsonObject.getInteger("alexa");
JSONObject sites = jsonObject.getJSONObject("sites");
String site1 = jsonObject.getJSONObject("sites").getString("site1");
JSONObject sites1 = jsonObject.getJSONArray("sites").getJSONObject(0);
JSONArray jsonArray= jsonObject.getJSONArray("sites")
for (int i = 0; i < jsonArray.size(); i++) {
String label = jsonArray.getJSONObject(i).getString("label");
}
JSONObject jsonObject = new JSONObject(new LinkedHashMap());
jsonObject.put("errcode","200");
jsonObject.put("errmsg","OK");
LinkedHashMap<String, Object> contentMap = JSON.parseObject(field, LinkedHashMap.class, Feature.OrderedField);
JSONObject jsonObject = new JSONObject(true);
jsonObject .putAll(contentMap);
JSONObject.toJSONString(result, SerializerFeature.WriteMapNullValue)
}