-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
Oj::StringWriter: Formatting options only partially applied #749
Comments
Just skimming over void oj_str_writer_init(StrWriter sw, int buf_size) {
sw->opts = oj_default_options;
// ...
sw->out.opts = &sw->opts;
sw->out.indent = sw->opts.indent;
// ...
sw->out.ropts = NULL;
sw->out.omit_nil = oj_default_options.dump_opts.omit_nil;
} https://github.com/ohler55/oj/blob/develop/ext/oj/string_writer.c#L43-L72 This looks like Going back to the class docs: http://www.ohler.com/oj/doc/Oj/StringWriter.html#new-class_method
I'm not sure what the second sentence suggests; could that be the reason? I am not calling into either of those. |
StringWriter and StreamWriter are meant as a convenient way to write JSON without creating a bunch of Ruby objects. Currently it does not support the special dump options. I had no plans to expand the capabilities as the idea was to keep the writer fast and adding the various options would add additional overhead. Maybe I should update the docs to make that clear. My apologies. |
According to https://github.com/ohler55/oj/blob/v3.10.6/pages/Modes.md, the
:rails
mode should support thespace
formatting option. However, this does not seem to work when using aStringWriter
; only some of the options given below are applied:indent
is applied, butspace
is not. I found this to be true for other options such asarray_nl
, which appears to be ignored. I also tried using:custom
mode, which equally ignores these options.The text was updated successfully, but these errors were encountered: