轉換代碼:
String[] comments = json2.getString(KEY_COMMENT);
KEY_COMMENT 是包含很多評論的字符串,這些評論都放在PHP數組中,然後返回給電話轉換成Json 字符串。應該怎麼轉換成數組?
下面是類似評論的例子
07-08 20:33:08.227: E/JSON(22615): {
"tag":"collectComments",
"success":1,
"error":0,
"numberOfComments":16,
"offsetNumber":1,
"comment":["test 16",
"test 15",
"test 14",
"test 13",
"test 12",
"test 11",
"test 10",
"test 9",
"test 8",
"test 7",
"test 6",
"test 5",
"test 4",
"test 3",
"test 2",
"test 1"]}n
讀出的String轉化成Json
JsonObject jo = new Json(data);
JsonArrray ja = jo.getJSONArray("comment");
for循環