-
Notifications
You must be signed in to change notification settings - Fork 541
Closed
Labels
Milestone
Description
问题描述
该方法在开启JSONReader.Feature.SupportSmartMatch模式后,只能解析最外层的下划线变量,内层无法解析到,例如下面的dept_order_list中的dept_id获取到的值为空
{
"errcode": 0,
"errmsg": "ok",
"result": {
"active": true,
"admin": false,
"avatar": "",
"boss": false,
"create_time": "2024-05-14T08:05:45.000Z",
"dept_id_list": [
111111111
],
"dept_order_list": [
{
"dept_id": 111111111,
"order": 1111111111111
}
],
"email": "",
"exclusive_account": false,
"hide_mobile": false,
"leader_in_dept": [
{
"dept_id": 862258146,
"leader": false
}
],
"mobile": "11111111111",
"name": "张三",
"real_authed": false,
"remark": "",
"senior": false,
"state_code": "86",
"telephone": "",
"title": "开发部",
"unionid": "IKKo8dfdfdfdfiSfn2nJEOwiEiE",
"userid": "zhangsan",
"work_place": ""
},
"request_id": "16khdfdfsdfkv560dw"
}
bean对象:
@Data
public class DDUserInfo {
/**
* The extension field, represented as a String.
*/
private String extension;
/**
* The unionid field, represented as a String.
*/
private String unionid;
/**
* The boss field, represented as a String.
*/
private String boss;
/**
* A list of roles associated with the user.
*/
private List<Role> roleList;
/**
* A boolean indicating whether the account is exclusive.
*/
private boolean exclusiveAccount;
/**
* The manager's user id, represented as a String.
*/
private String managerUserid;
/**
* The admin field, represented as a String.
*/
private String admin;
/**
* Any remarks associated with the user, represented as a String.
*/
private String remark;
/**
* The title of the user, represented as a String.
*/
private String title;
/**
* The date the user was hired, represented as a String.
*/
private String hiredDate;
/**
* The user's id, represented as a String.
*/
private String userid;
/**
* The user's workplace, represented as a String.
*/
private String workPlace;
/**
* The order of the employee in the corresponding department.
*/
private List<DeptOrder> deptOrderList;
/**
* A String indicating whether the user is authed in real life.
*/
private String realAuthed;
/**
* A list of department ids associated with the user, represented as a String.
*/
private String deptIdList;
/**
* The user's dept, represented as a String.
*/
private String deptName;
/**
* The user's job number, represented as a String.
*/
private String jobNumber;
/**
* The user's email, represented as a String.
*/
private String email;
/**
* Information about the user's position in the department and whether they are a leader.
*/
private List<LeaderInDept> leaderInDept;
/**
* The user's mobile number, represented as a String.
*/
private String mobile;
/**
* A String indicating whether the user is active.
*/
private String active;
/**
* The user's organization email, represented as a String.
*/
private String orgEmail;
/**
* The user's telephone number, represented as a String.
*/
private String telephone;
/**
* The user's avatar, represented as a String.
*/
private String avatar;
/**
* A String indicating whether the user's mobile number is hidden.
*/
private String hideMobile;
/**
* A String indicating whether the user is a senior.
*/
private String senior;
/**
* The user's name, represented as a String.
*/
private String name;
/**
* Extended information about the user's union membership.
*/
// private UnionEmpExt unionEmpExt;
/**
* The user's state code, represented as a String.
*/
private String stateCode;
@Data
public static class LeaderInDept {
private String leader;
private Long deptId;
}
@Data
public static class DeptOrder {
private Long deptId;
private String order;
}
@Data
public static class Role {
private String groupName;
private String name;
private Long id;
}
}
环境信息
请填写以下信息:
- OS信息: win11
- JDK信息: jdk 1.8.0_321]
- 版本信息:Fastjson2 2.0.50
重现步骤
public static void main(String[] args) {
String jsn = "{\n" +
" \"errcode\": 0,\n" +
" \"errmsg\": \"ok\",\n" +
" \"result\": {\n" +
" \"active\": true,\n" +
" \"admin\": false,\n" +
" \"avatar\": \"\",\n" +
" \"boss\": false,\n" +
" \"create_time\": \"2024-05-14T08:05:45.000Z\",\n" +
" \"dept_id_list\": [\n" +
" 111111111\n" +
" ],\n" +
" \"dept_order_list\": [\n" +
" {\n" +
" \"dept_id\": 111111111,\n" +
" \"order\": 1111111111111\n" +
" }\n" +
" ],\n" +
" \"email\": \"\",\n" +
" \"exclusive_account\": false,\n" +
" \"hide_mobile\": false,\n" +
" \"leader_in_dept\": [\n" +
" {\n" +
" \"dept_id\": 862258146,\n" +
" \"leader\": false\n" +
" }\n" +
" ],\n" +
" \"mobile\": \"11111111111\",\n" +
" \"name\": \"张三\",\n" +
" \"real_authed\": false,\n" +
" \"remark\": \"\",\n" +
" \"senior\": false,\n" +
" \"state_code\": \"86\",\n" +
" \"telephone\": \"\",\n" +
" \"title\": \"开发部\",\n" +
" \"unionid\": \"IKKo8dfdfdfdfiSfn2nJEOwiEiE\",\n" +
" \"userid\": \"zhangsan\",\n" +
" \"work_place\": \"\"\n" +
" },\n" +
" \"request_id\": \"16khdfdfsdfkv560dw\"\n" +
"}";
JSONObject o = JSON.parseObject(jsn);
JSONObject result = o.getJSONObject("result");
DDUserInfo javaObject = result.toJavaObject(DDUserInfo.class, JSONReader.Feature.SupportSmartMatch);
System.out.println(javaObject);
}