JSONObject root =
new
JSONObject();
JSONObject cat =
new
JSONObject();
cat.put(
"cat"
,
"miao"
);
JSONArray array =
new
JSONArray();
JSONObject lan1 =
new
JSONObject();
lan1.put(
"id"
,
1
).put(
"ide"
,
"Eclispe"
).put(
"name"
,
"java"
);
JSONObject lan2 =
new
JSONObject();
lan2.put(
"id"
,
2
).put(
"ide"
,
"Xcode"
).put(
"name"
,
"Swift"
);
JSONObject lan3 =
new
JSONObject();
lan3.put(
"id"
,
3
).put(
"ide"
,
"Visual Studio"
).put(
"name"
,
"C++"
);
array.put(lan1);
array.put(lan2);
array.put(lan3);
root.put(
"languages"
, array);
root.put(
"cat"
, cat);
大神博客!
http://www.cnblogs.com/jycboy/p/json_xj.html