天天看點

JsonObject JsonArray String互相轉化

JsonObject JsonArray String互相轉化

##包 import com.alibaba.fastjson.JSONArray;

import com.alibaba.fastjson.JSONObject;

1.String轉JSONObject

String s = new String();

JSONObject js = JSONObject.parseObject(s);

2.JSONObject轉String

String s = jsonObject2.getString("//key");

3.String轉JSONArray

String s = new String;

JSONArray jsonArray = JSONArray.parseArray(s);

4.周遊JSONArray(轉JSONObject)

String s = new String();

JSONArray jsonArray = JSONArray.parseArray(s);

for (int i = 0;i<jsonArray.size();i++){

JSONObject jsonObject1 = jsonArray.getJSONObject(i);

}