-
Notifications
You must be signed in to change notification settings - Fork 64
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
Option to encode empty table as array #23
Comments
Noted and work in progress. Hold on. |
Thanks! I think the detection code "if something is an array" is not correct. |
It is just a choice. For any non empty table with length > 0, will treat as array. |
ccd02f2 Added empty_table_as_array option for rapidjson.encode(). You can have it a try. |
Thanks, I'll try later. If this does not not support mixed hash and array tables (separate option is ok), then I can't replace cjson with lua-rapidjson. This is not compatible with any other lua json library. |
I tested this with nested arrays, it works. I think I can use this in most-used user case: sending json from my luajit server to browser. I know that I do not have mixed json there. |
I changed in pretty json 4 spaces to one tab (saves space in big json): I had some trouble to change CMakeLists.txt to use sse2 or sse4.2 (osx, win and linux), if somebody needs info I can give it. This library is really fast, first one to beat cjson (and msgpack). Thanks again! |
Hello.
Is it possible for empty Lua tables {} to return "[]" instead of "{}"?
Lua cjson has this option: cjson.encode_empty_table_as_object(false). I can use __jsontype, but then I would need to attach it to all possible deep elements.
I mean {a={}} => {"a": []}.
The text was updated successfully, but these errors were encountered: