对比分析json及XML(9)
复制代码 代码如下: private String createJson() throws JSONException { JSONObject jsonObject = new JSONObject(); jsonObject.put("intKey", 123); jsonObject.put("doubleKey", 10.1); jsonObject.put
复制代码 代码如下:
private String createJson() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.put("intKey", 123);
jsonObject.put("doubleKey", 10.1);
jsonObject.put("longKey", 666666666);
jsonObject.put("stringKey", "lalala");
jsonObject.put("booleanKey", true);
JSONArray jsonArray = new JSONArray();
jsonArray.put(0, 111);
jsonArray.put("second");
jsonObject.put("arrayKey", jsonArray);
JSONObject innerJsonObject = new JSONObject();
innerJsonObject.put("innerStr", "inner");
jsonObject.put("innerObjectKey", innerJsonObject);
Log.e("Json", jsonObject.toString());
return jsonObject.toString();
}
其输出结果如下所示:
精彩图集
精彩文章