Skip to content

Moving from FastWriter to StreamWriterBuilder #513

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

Closed
cmaeckel opened this issue Aug 8, 2016 · 0 comments
Closed

Moving from FastWriter to StreamWriterBuilder #513

cmaeckel opened this issue Aug 8, 2016 · 0 comments

Comments

@cmaeckel
Copy link

cmaeckel commented Aug 8, 2016

I'm changing all my code to move off the deprecated classes and methods (it is odd that they are not all marked with JSONCPP_DEPRECATED) and came across a change in the output when moving from FastWriter to StreamWriterBuilder. So it looks like setting the indentation to an empty string does most of compatibility but the commas in arrays still have spaces after them. I've patched my version but it would be nice to put this in the official distribution.

--- /Before/json_writer.cpp 2016-08-08 15:29:32.000 -0500
+++ /After/json_writer.cpp  2016-08-08 15:29:59.000 -0500
@@ -1002,7 +1002,7 @@
       if (!indentation_.empty()) *sout_ << " ";
       for (unsigned index = 0; index < size; ++index) {
         if (index > 0)
-          *sout_ << ", ";
+          *sout_ << ((!indentation_.empty()) ? ", " : ",");
         *sout_ << childValues_[index];
       }
       if (!indentation_.empty()) *sout_ << " ";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant