Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONBody 序列化错误 #214

Open
PeterFangXiaoLin opened this issue Nov 20, 2024 · 1 comment
Open

JSONBody 序列化错误 #214

PeterFangXiaoLin opened this issue Nov 20, 2024 · 1 comment

Comments

@PeterFangXiaoLin
Copy link

接口代码:

    @Post("/addProject.do")
    ProjectRespVO addProject(@JSONBody ProjectAddReqVO projectAddReqVO);

ProjectAddReqVO

import cn.com.huaruan.hrcodeframe.allplatform.thirdapi.vo.user.UserVO;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;

@Data
@Builder
public class ProjectAddReqVO implements Serializable {
    // 项目名称
    private String projectName;

    // 项目编号
    private String projectCode;

    // 项目日期  格式:YYYY-MM-DD
    // @JsonProperty("pDate")
    private LocalDate pDate;

    // 建设单位
    private String jsdw;

    // 分院ID 默认-1
    private Integer branchDeptId; // 分院ID,默认-1

    // 项目负责部门ID(可选)
    private String pmpDeptId;

    // 项目负责人
    private List<UserVO> pmpUser;
    // 项目注册负责人
    private List<UserVO> zcUser;
}

结果

Headers: 
		User-Agent: forest/1.5.36
		Content-Type: application/json
	Body: {"PDate":"2024-11-20","branchDeptId":-1,"jsdw":"测试","pmpUser":[{"userId":"123","userName":"测试"}],"projectCode":"测试","projectName":"测试项目","zcUser":[{"userId":"123","userName":"测试"}]}

经过测试,只要是一个字母的驼峰转换,最后都会变成大写,例如 pHello -> PHello

这是BUG吗?

  • 目前我的解决是加上 @JsonProperty 注解
@witt-bit
Copy link
Contributor

这个lombok的问题,具体查询lombok相关,lombok对于单个字母的gettersetter与jackson处理不一致

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants