Open 337077418 opened 1 month ago
跑完得到的是所有null的参数都被跳过 { "code": 1, "data": { "auth": [], "order": { "address": "测试11111111111111111111111111", "agency_name": "测试三组", "agency_owner_admin_name": "测试管理员", "agency_owner_name": "测试三组", "create_time": "2024-07-06", "end_time": "2026-07-05", "id": 1863, "money": "25.00", "number": "2024070618060434152", "order_state_name": "作废", "order_type": 1, "pay_state_name": "待处理", "peer_price": "0.10", "produce_cate_code": 10000, "product_id": 2295, "product_name": "测试123456789", "start_time": "2024-07-06", "state": 4, "store_name": "测试组织三", "unit": "月" } }, "msg": "" }
你直接在类的字段上面定义一个默认值,当后台没有返回这个字段的时候,或者返回为 null 的时候,框架会跳过解析和赋值,这个时候字段上面的值还是你当时给的那个。
大佬,我能在整个解析过程中,获取到一个我在JavaBean中未定义的属性值吗?比如后端返回的结构体中统一增加了一个tr的字段,但是我所有的Java Bean (Data Class)都没有定义这个字段,按照Gson的解析流程会将未定义的字段都过滤掉,但是我这时想要拿到这个tr字段,应该如何做呢?
@15110052956 你这个是另外的问题,需要提一个新的 issue,不要在其他人的 issue 下留言。
Question Description [Required]
或者说大佬你已经做了我没发现用法? 我测试好像目前都是遇到null字段都会跳过解析 我的json:
{"code":1,"msg":"","data":{"order":{"id":1863,"number":"2024070618060434152","customer_id":null,"produce_cate_code":10000,"product_id":2295,"state":4,"pay_status":null,"store_name":"测试组织三","customer_name":null,"product_name":"测试123456789","linkman":null,"mobile":null,"contacts":null,"contacts_mobile":null,"run":null,"order_type":1,"agency_name":"测试三组","agency_admin_name":null,"agency_owner_name":"测试三组","agency_owner_admin_name":"测试管理员","money":"25.00","start_time":"2024-07-06","end_time":"2026-07-05","create_time":"2024-07-06","address":"测试11111111111111111111111111","unit":"月","peer_price":"0.10","order_state_name":"作废","pay_state_name":"待处理"},"auth":[]}}
Is the issue mentioned in the framework documentation? [Required]
No
Did you consult the framework documentation but couldn't find a solution? [Required]
Yes
Has a similar issue been reported in the issue list? [Required]
No
Have you searched the issue list but couldn't find a solution? [Required]
Yes