我在这个格式的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) –