如何将此 JSON 转换为对象?
最佳答案
您可以使用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);
关于java - 如何将此 JSON 转换为 JAVA android 中的对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60750796/