JSONArray json = new JSONArray();
JSONObject jo = new JSONObject();
for (RechargeRecord pLog : rechargeList) {
jo.put("id", pLog.getId());
jo.put("time", pLog.getNickName());
}
JSONArray json1 = new JSONArray();
JSONObject jo1 = new JSONObject();
json1.put(jo);
System.out.println(json1.put(jo));
jo1.put("allUser", json1);
jo1.put("type", 1);
jo1.put("name", "name");
json.put(jo1);
System.out.println("jo1\t" + json);
System.out.println(object.get("result").getAsJsonObject().get("formatted_address"));
全部是json时
{"status":{"errorCode":0,"msg":"成功"},"data":"","url":""}
String status = object.get("status").getAsJsonObject().get("errorCode").getAsString();
String msg = object.get("status").getAsJsonObject().get("msg").getAsString();
String data = object.get("data").getAsString();
String url = object.get("url").getAsString();
获取json数组时
JsonArray array = object.get("data").getAsJsonArray();
for (int i = 0; i < array.size(); i++) {
JsonObject subObject = array.get(i).getAsJsonObject();
System.out.println("expect=" + subObject.get("expect").getAsString());
}
json和json字符串转化
猜你喜欢
转载自blog.csdn.net/qq_41000382/article/details/87871924
今日推荐
周排行