Skip to content

兼容jackjson中access中的READ_ONLY跟WRITE_ONLY修复 - #830

Merged
wenshao merged 3 commits into
alibaba:mainfrom
scrollsyou:main
Oct 14, 2022
Merged

兼容jackjson中access中的READ_ONLY跟WRITE_ONLY修复#830
wenshao merged 3 commits into
alibaba:mainfrom
scrollsyou:main

Conversation

@scrollsyou

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

目前当系统使用到jackson跟fastjson2后,使用jackson
@JsonProperty(value = "password", access = JsonProperty.Access.WRITE_ONLY)
注解后,bean类序列化为json时返回前端不带password字段,该现象为正常的。
但通过JSON.parseObject(jsonObject.toJSONString(), SysUser.class);得到的bean中password为空
同时当user.setPassword("54321");System.out.println(JSON.toJSONString(user));时输出json中带password字段值

Summary of your change

对ObjectWriterBaseModule跟ObjectReaderBaseModule中字段对调

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

@CLAassistant

CLAassistant commented Oct 11, 2022

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@wenshao

wenshao commented Oct 11, 2022

Copy link
Copy Markdown
Member

请签署CLA

@wenshao wenshao added this to the 2.0.16 milestone Oct 11, 2022
@scrollsyou

Copy link
Copy Markdown
Contributor Author

好的,签署了

@wenshao

wenshao commented Oct 14, 2022

Copy link
Copy Markdown
Member

显示还没签署CLA,同时这个PR导致JsonPropertyTest1跑不过,这个Testcase也一起改了吧

@scrollsyou

Copy link
Copy Markdown
Contributor Author

好的,抱歉没看下方报错

@wenshao wenshao added the bug Something isn't working label Oct 14, 2022
@wenshao
wenshao merged commit 6ade462 into alibaba:main Oct 14, 2022
@wenshao

wenshao commented Oct 22, 2022

Copy link
Copy Markdown
Member

https://github.com/alibaba/fastjson2/releases/tag/2.0.16
问题已修复,请用2.0.16版本

@ltsznh

ltsznh commented Apr 7, 2023

Copy link
Copy Markdown

JsonProperty.Access.WRITE_ONLY || access = JsonProperty.Access.READ_ONLY
支持jackson JsonProperty的问题修复很好。但是带来的问题是后台redis缓存序列化和反序列化的时候还想要保留所有字段。
修复该bug后没有给出一个方法可以强制序列化所有字段,忽略WRITE_ONLY或者READ_ONLY;建议在JSONWriter.Feature增加相关Feature,用户可以手工指定忽略WRITE_ONLY或者READ_ONLY。
望采纳,谢谢!
目前只能在2.0.2版本,等待支持手工强制序列化、反序列化所有字段的版本出现。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants