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

通过cjson序列化pb.decode中空数组的问题 #197

Open
doudouliyougangbeng opened this issue May 21, 2022 · 3 comments · May be fixed by #199
Open

通过cjson序列化pb.decode中空数组的问题 #197

doudouliyougangbeng opened this issue May 21, 2022 · 3 comments · May be fixed by #199

Comments

@doudouliyougangbeng
Copy link

由于lua中没有数组概念,pb.decode会把空数组当成空table,当cjson进行decode时就会序列化为{}。
现在cjson支持cjson.decode_array_with_array_mt(true)即当setmetatable({}, array_mt)时就会序列化[]。
我现在的做法为,递归所有属性,找到"repeated"的空table,进行设置
image
这种感觉非常不友好而且严重影响性能,有没有从pb方面就能很好的解决问题的方法呢?

@starwing
Copy link
Owner

可以讨论下看看有什么比较好的方案

@bugwang
Copy link

bugwang commented Jul 19, 2023

[] {} 都设置成 nil

@starwing
Copy link
Owner

可以考虑pb.defaults("*array", array_mt)

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

Successfully merging a pull request may close this issue.

3 participants