android - 如何使用字符串请求从 JSON 文件中检索数据

标签 android json

enter image description here

如何获取翻译后的文本?

 JsonObject json = new JsonObject(response);
 JsonObject data = json.getJsonObject("data").getString("translations").getString("translated Text");

最佳答案

translations 是一个 JsonArray,因此您必须将其作为数组获取。

JsonObject json = new JsonObject(response);
JsonObject data = json.getJsonObject("data");
JsonArray transalations = data.getJsonArray("transalations");
String translatedText = transalations.getJsonObject(0).getString("translatedText");

关于android - 如何使用字符串请求从 JSON 文件中检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48738263/

相关文章:

asp.net-mvc - 有没有办法让Ajax.BeginForm返回JSON并自动更新Form

ios - 使用 NSJSONSerialization.JSONObjectWithData() 解析数据但无法仅访问数组组字符串

java - 如何正确解析这个 JSON?

json - 如何使用 lodash 将字符串连接到现有数组元素

java - 选择动态创建的线性布局 View

android - android 中是否有与 iphone 中相同的默认谷歌地图标记?

android - 引用外部类

java - 制作一个倒计时器

android - 在导航 Controller 上添加 fragment 而不是替换 fragment ?

json - Spring MVC : post request and json object with array : bad request