我刚开始使用JSON,我遇到了一些困难。我正在使用Kitsu API并解析我登录时获得的JSON。当我解析我的json时,会弹出下面的图片,但是在1Object数组中,我想要在attributes对象中获取头像对象中的大url,但我不知道如何获取。The beginning of the JSON、The middle of the JSON、The end。最后,我想知道如何编辑JSON的slug部分,如果你不知道这很酷,主要的事情是获得头像的url。
发布于 2019-03-08 06:21:50
请试试这个..。
JSONObject myObject = new JSONObject(jsonStr);
JSONArray myArray = myObject.getJSONArray("data");
JSONObject obj = myArray.getJSONObject(0);
String id = obj.getString("id");
String type = obj.getString("type");
//change the lines bellow
JSONObject attributes = obj.getJSONObject("attributes");
JSONObject avatar = attributes.getJSONObject("avatar");
String large = avatar.getString("large");
https://stackoverflow.com/questions/55053622
复制相似问题