Skip to content

Commit 5e36f95

Browse files
committed
Fixed serious problem in beautifier, that broke values.
1 parent 3ca2c00 commit 5e36f95

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

utility/beauty_stream.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace JSON
44
{
55
BeautifiedStreamWrapper::BeautifiedStreamWrapper()
6-
: indentation_(0)
6+
: indentation_(0)
7+
, escape_(false)
8+
, disabled_(false)
79
, nestingStack_()
810
{
911
nestingStack_.push(NestingState::IN_CLASS);

utility/beauty_stream.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,21 @@ namespace JSON
3232
template <typename Sink>
3333
bool put(Sink& snk, char c)
3434
{
35-
namespace io = boost::iostreams;
35+
namespace io = boost::iostreams;
36+
37+
escape_ = false;
38+
if (disabled_)
39+
if (c == '\\')
40+
escape_ = true;
41+
42+
if (c == '"' && !escape_)
43+
disabled_ = !disabled_;
44+
45+
if (disabled_)
46+
{
47+
io::put(snk, c);
48+
return true;
49+
}
3650

3751
if (c == '{')
3852
{
@@ -83,7 +97,9 @@ namespace JSON
8397
}
8498

8599
private:
86-
int indentation_;
100+
int indentation_;
101+
bool escape_;
102+
bool disabled_;
87103
std::stack <NestingState> nestingStack_;
88104
};
89105
}

0 commit comments

Comments
 (0)