java - 如何将此 JSON 转换为 JAVA android 中的对象?

标签 java android json

如何将此 JSON 转换为对象?

enter image description here

最佳答案

您可以使用Gson

Gson a Java serialization/deserialization library to convert Java Objects into JSON and back

首先你应该将此代码行放在gradle上

dependencies {
  implementation 'com.google.code.gson:gson:2.8.6'
 }

如果你使用maven添加如下

<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.8.6</version>
 </dependency>

最后在获取 json 字符串之后,

String json = "here your json string";

Gson gson = new Gson();

YOURCLASS yourclass = gson.fromJson(json, YOURCLASS.class);

Another using examples here

关于java - 如何将此 JSON 转换为 JAVA android 中的对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60750796/

相关文章:

具有指定标签的 PHP Json 值

java - Gson 用键解析数组的数组

java - 为什么从方法返回时我的 ResultSet 变空?

android - 如何在 android 的自定义 TextView 控件中更改字母的颜色?

android - 如何隐藏自定义选项卡的 URL?

android - 错误 :Attribute "color" has already been defined, 更新 appcompat v-7

java - 使用 JACKSON 将 JAXB 转换为 JSON

java - 如何在JAVA中计算soap消息体的大小

java - h264原始数据流和Android中的渲染

java - 在 JTabbedPane 中拆分标签