gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 00:07:25 26 4
gpt4 key购买 nike

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com