Open phptalker opened 1 year ago
Fastjson 2 的输出是对的。你的期待才是不符合 JavaBean 规范的。
你应该使用了 @JSONField(name = "PageNo")
来自定义字段名称吧 ?
注意看一下你引用的注解的 包名。
你如果是从 Fastjson1 升级上来的,那你的 @JSONField
可能还是 Fastjson 1 的。
使用 Fastjson 2进行序列化,就要使用 Fastjson 2 的 @JSONField
注解。
QueryStationInfoParam 这个类代码相关的图片看不到,请补充一下
问题描述
简要描述您碰到的问题。
fastjson升级成2.025 JSONField 无效
环境信息
请填写以下信息:
重现步骤
如何操作可以重现该问题:
JSON.toJSONString
方法QueryStationInfoParam queryStationInfoParam = new QueryStationInfoParam(); queryStationInfoParam.setPageNo(100); queryStationInfoParam.setPageSize(100);
数据序列化结果和预期不一致
错误期待的正确结果
{"PageNo":100,"PageSize":100}
相关日志输出
{"pageNo":100,"pageSize":100}
附加信息