我在這個格式的JSON響應:遍歷JSON鍵獲取值
{"success":false,"errors":{"one":["First", "Second",...],"two":["First", "Second",...],...}}
的errors
對象可以有多個鍵,其中每個鍵可以具有一個或多個值。
我怎樣才能循環訪問鍵(在Java中)並獲得它們的值?
我當前的代碼:
JSONObject obj = new JSONObject(json);
String success = obj.getString("success"); // get success
JSONObject errors = obj.getJSONObject("errors"); // get errors
如果您不介意請使用JSON解析器,如[GSON](https://github.com/google/gson)。進一步看到這[SO帖子](http://stackoverflow.com/questions/22326169/which-is-the-best-way-to-parse-json-data-in-android) –