Skip to content

Moving from FastWriter to StreamWriterBuilder #513

@cmaeckel

Description

@cmaeckel

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_ << " ";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions