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

[疑惑]:在解析过程中能否给所有的Java Bean或 data class 添加一个未定义的字段 #48

Open
15110052956 opened this issue Jul 22, 2024 · 3 comments
Labels
question Further information is requested

Comments

@15110052956
Copy link

15110052956 commented Jul 22, 2024

问题描述【必填】

大佬,我能在整个解析过程中,获取到一个在Java Bean中未定义的属性值吗?
比如由于业务需要,后端在返回的结构体最外层统一新增加了一个tr的字段,但是我所有的Java Bean (Data Class)都未定义这个字段,按照Gson的解析流程会将未定义的字段都过滤掉,但是我这时想要拿到这个tr字段,并将这个字段添加给每一层级的Java Bean。

大致流程如下,原始Json是这样的

{
        "tr":"tr_map_value",
        "data": {
            "noticeMsgNum": "208",
            "order":{
                "orderId":"10086"
            }
        }
 }

但我想得到这样Json解析出来的结果

{
        "tr":"tr_map_value",
        "data": {
        "tr":"tr_map_value",
        "noticeMsgNum": "208", 
        "order":{
            "tr":"tr_map_value", 
            "orderId":"10086"
           }
        }
}

想了半天,如果想要统一处理,好像只能在解析这一步做操作了。但搞了半天一点头绪都没有,所以想问问大佬您能给些建议吗

框架文档是否提及了该问题【必答】

是否已经查阅框架文档但还未能解决的【必答】

issue 列表中是否有人曾提过类似的问题【必答】

是否已经搜索过了 issue 列表但还未能解决的【必答】

@15110052956 15110052956 added the question Further information is requested label Jul 22, 2024
@getActivity
Copy link
Owner

image

@getActivity
Copy link
Owner

小伙子,这种问题我不会给予解答,因为这个属于你个人遇到的技术问题,并非框架的问题,需要你自行解决,我只处理框架相关的问题。

@15110052956
Copy link
Author

好的,没问题,能理解的

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

No branches or pull requests

2 participants