{ "data": [ { "id": "9", "topic": "fffff", "price": "99", "datetime": "2015-05-21 07:27:36", "status": "2", "image_0": "151a5880c3a4ede138b52163bfda226f", "path_file": "dab20bb2a195e15628f52daa913889f8" }, { "id": "8", "topic": "fffff", "price": "99", "datetime": "2015-05-21 07:25:54", "status": "1", "image_0": "355b26cf1183a6f82e3e81b512a0dda4", "path_file": "018143a91e7c37c1a2d84f400cea6e46" }, { "id": "7", "topic": "fffff", "price": "99", "datetime": "2015-05-21 07:24:37", "status": "1", "image_0": "0d83e16635ff143aa8d12b5228ca5b1e", "path_file": "97c9c9175f438526d821437623108e9e" }, { "id": "6", "topic": "testtopic11111", "price": "777", "datetime": "2015-05-19 10:46:20", "status": "1", "image_0": "826f6fa451e3320aba83c18dd5e21b15", "path_file": "d96f99003e86fae9f0fcfc096bf1c786" }, { "id": "5", "topic": "testtopic11111", "price": "777", "datetime": "2015-05-19 10:45:25", "status": "1", "image_0": "a256835d411a1e6e32baf0812cfb3d85", "path_file": "2ee5adc08f04e8b6ef794840a7511726" }, { "id": "4", "topic": "testttttttttttt111", "price": "99", "datetime": "2015-05-19 09:13:17", "status": "1", "image_0": "30830ef276746d78bc7448b237a2e042", "path_file": "2aaf4427ca7d8ae6dcbd914525acf4d6" }, { "id": "3", "topic": "ทดสอบระบบ 2", "price": "999999999", "datetime": "2015-05-18 06:55:06", "status": "1", "image_0": "907215bc02fee9c0374e6cc2b4768b18", "path_file": "57ecae9c9e20b90bfa5d53baef025b85" }, { "id": "2", "topic": "ttttttttttttttt2", "price": "220000", "datetime": "2015-05-18 06:39:27", "status": "1", "image_0": "11a80afa28a91adef8d16305bcb19125", "path_file": "75e68fbf2486cd7cfdab6cfe09971f77" }, { "id": "1", "topic": "ttttttttttttttttopic1", "price": "99999", "datetime": "2015-05-17 16:30:35", "status": "1", "image_0": "a1a24f36ce52818ef2655310d8a31dbb", "path_file": "dd39b8afc9e84d3a47cbbad5c13bdfbb" } ] }
ประกอบด้วย JSON Array ชื่อ : data
Key ที่เก็บคือ : id , topic , price , datetime , status , image_0 , path_file
การอ่านข้อมูล JSON (Json Parse)
JSONObject json_obj = new JSONObject(response);
JSONArray json_array = json_obj.getJSONArray("data");
เมื่อ Log.e("json_array", json_array.toString());
[ { "id": "9", "topic": "fffff", "price": "99", "datetime": "2015-05-21 07:27:36", "status": "2", "image_0": "151a5880c3a4ede138b52163bfda226f", "path_file": "dab20bb2a195e15628f52daa913889f8" }, { "id": "8", "topic": "fffff", "price": "99", "datetime": "2015-05-21 07:25:54", "status": "1", "image_0": "355b26cf1183a6f82e3e81b512a0dda4", "path_file": "018143a91e7c37c1a2d84f400cea6e46" }, { "id": "7", "topic": "fffff", "price": "99", "datetime": "2015-05-21 07:24:37", "status": "1", "image_0": "0d83e16635ff143aa8d12b5228ca5b1e", "path_file": "97c9c9175f438526d821437623108e9e" }, { "id": "6", "topic": "testtopic11111", "price": "777", "datetime": "2015-05-19 10:46:20", "status": "1", "image_0": "826f6fa451e3320aba83c18dd5e21b15", "path_file": "d96f99003e86fae9f0fcfc096bf1c786" }, { "id": "5", "topic": "testtopic11111", "price": "777", "datetime": "2015-05-19 10:45:25", "status": "1", "image_0": "a256835d411a1e6e32baf0812cfb3d85", "path_file": "2ee5adc08f04e8b6ef794840a7511726" }, { "id": "4", "topic": "testttttttttttt111", "price": "99", "datetime": "2015-05-19 09:13:17", "status": "1", "image_0": "30830ef276746d78bc7448b237a2e042", "path_file": "2aaf4427ca7d8ae6dcbd914525acf4d6" }, { "id": "3", "topic": "ทดสอบระบบ 2", "price": "999999999", "datetime": "2015-05-18 06:55:06", "status": "1", "image_0": "907215bc02fee9c0374e6cc2b4768b18", "path_file": "57ecae9c9e20b90bfa5d53baef025b85" }, { "id": "2", "topic": "ttttttttttttttt2", "price": "220000", "datetime": "2015-05-18 06:39:27", "status": "1", "image_0": "11a80afa28a91adef8d16305bcb19125", "path_file": "75e68fbf2486cd7cfdab6cfe09971f77" }, { "id": "1", "topic": "ttttttttttttttttopic1", "price": "99999", "datetime": "2015-05-17 16:30:35", "status": "1", "image_0": "a1a24f36ce52818ef2655310d8a31dbb", "path_file": "dd39b8afc9e84d3a47cbbad5c13bdfbb" } ]
Thank JSON Pretty Print : http://www.freeformatter.com/json-formatter.html
เรื่องต่อไป ...การเข้าถึง JSONArray ....