我有一個JSON文件。我需要只獲得一組ID值(30461,...)如何解碼JSON文件以接收帶有json-simple庫的id值數組?
{
"response":[
5205,
{
"id":30461, // target value!
"from_id":-52078741,
"to_id":-52078741,
"date":1459435510
...
如何接收ID值數組?
JSONParser parser = new JSONParser();
Object obj = parser.parse(new FileReader("C://json_file.txt"));
JSONArray array = new JSONArray();
JSONObject obj_j = (JSONObject) obj;
array.add(obj_j);
System.out.println(array);
鏈接到整個JSON文件: https://api.vk.com/method/wall.get?domain=just_eng&offset=1&counts=100
對不起,但我不確定你面臨什麼問題。你的Json表示在'response'鍵中存儲的對象,該對象在'位置1'存儲具有'id'鍵的對象,並且你想獲得該值。這是相當直接的解析。我誤解了你的意思嗎,或者你的代碼有任何特定的問題嗎? – Pshemo
請分享一些json以正確理解它的結構。 – Braj
@CacheStaheli基於標籤,它是json簡單的庫。 – Pshemo