gpt4 book ai didi

java - 如何在 GWT 中使用 JSNI 覆盖类型提取嵌套 JSON 对象?

转载 作者:行者123 更新时间:2023-12-01 12:29:14 24 4
gpt4 key购买 nike

所以我收到了这个 JSON 对象,其格式大致如下:

{   "student":{"field1":"","field2":"",....},
"subjects":[{},{},....,{}] }

如何使用覆盖类型和 JsonUtils 方法提取 GWT 中“student”的全部内容以及“subjects”数组中的每个对象?

最佳答案

看起来你的学生是一个嵌套的 Json 对象

JSONObject obj = new JSONObject(jsonString);
JSONObject mystudent = obj.getJSONObject("student");
String myfield1 = mystudent.getString("field1");

“Subjects”看起来像一个数组......为此你可以使用 JSONArray 和 getJavaScriptObject() http://www.gwtproject.org/javadoc/latest/com/google/gwt/json/client/JSONArray.html

关于java - 如何在 GWT 中使用 JSNI 覆盖类型提取嵌套 JSON 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26081594/

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