我是一个关于 JSON 的初学者......
如何从 Java 程序中的以下 JSON 对象中获取“3037904”的值?
{"query":{"pages":{"3037904":{"pageid":3037904,"ns":0,"title":"Kempinski", "categories":[{"ns":14,"title ":"Category:1897 年成立的公司"},{"ns":14,"title":"Category:连锁酒店"},{"ns":14,"title":"Category:Kempinski Hotels"}] }}}}
我尝试过了
JSONObject query = json.getJSONObject("query");
int pages = query.getInt("pages");
但这需要
"{"3037904":{"pageid":3037904,"ns":0,"title":"Kempinski",
"categories":[{"ns":14,"title":"Category:Companies established in 1897"},{"ns":14,"title":"Category:Hotel chains"},{"ns":14,"title":"Category:Kempinski Hotels"}]}}}}",
不仅是“3037904”。