【发布时间】:2020-06-28 19:25:56
【问题描述】:
这是我的 json 字符串,因为我想将它转换为 Java 类:
"result": {
"id": "39559",
"first_name": "John",
"last_name": "Who",
"gender": "male",
"dob": null,
"email": "john.who@roberts.com",
"phone": null,
"website": null,
"address": null,
"status": "active",
"_links": {
"self": {
"href": "https://gorest.co.in/public-api/users/39559"
},
"edit": {
"href": "https://gorest.co.in/public-api/users/39559"
},
"avatar": {
"href": null
}
}
}
这是我的课(我删除了 getter 和 toString):
public class Result {
String id, user_id, title, first_name, last_name, gender, dob, email, phone,
website, address, status, _links, album_id, url, thumbnail, post_id, name, body;
}
我想知道我该如何代表
"_links": {
"self": {
"href": "https://gorest.co.in/public-api/users/39559"
},
"edit": {
"href": "https://gorest.co.in/public-api/users/39559"
},
"avatar": {
"href": null
}
}
如何在我的 Result 类中表示缺失的部分?
【问题讨论】: