首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何搜索JSON对象的特定部分并添加到已存在的对象中

如何搜索JSON对象的特定部分并添加到已存在的对象中
EN

Stack Overflow用户
提问于 2019-03-08 06:10:41
回答 1查看 43关注 0票数 0

我刚开始使用JSON,我遇到了一些困难。我正在使用Kitsu API并解析我登录时获得的JSON。当我解析我的json时,会弹出下面的图片,但是在1Object数组中,我想要在attributes对象中获取头像对象中的大url,但我不知道如何获取。The beginning of the JSONThe middle of the JSONThe end。最后,我想知道如何编辑JSON的slug部分,如果你不知道这很酷,主要的事情是获得头像的url。

Picture of my error

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-08 06:21:50

请试试这个..。

代码语言:javascript
复制
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");
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55053622

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档