Skip to content

Commit

Permalink
Added support for printing single values without escaping the strings
Browse files Browse the repository at this point in the history
Bumped version to 4.06.1
  • Loading branch information
cmorse committed Aug 15, 2013
1 parent cf7d228 commit 11f6ab3
Show file tree
Hide file tree
Showing 30 changed files with 48 additions and 32 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ enum Output_options
pretty_print = 0x01,
raw_utf8 = 0x02,
remove_trailing_zeros = 0x04,
single_line_arrays = 0x08
single_line_arrays = 0x08,
always_escape_nonascii = 0x10,
no_quote_strings = 0x20
};
```

Expand Down Expand Up @@ -225,6 +227,9 @@ on single lines unless they contain composite elements, i.e. objects or arrays.
}
```

The ```always_escape_nonascii``` option escapes all unicode wide characters, i.e. outputed as "\uXXXX" even if they
are printable under the current locale, ascii printable chars are not escaped.

You can apply more than one option by using the OR operator, i.e.:
```cpp
write( addr_obj, os, pretty_print | raw_utf8 );
Expand Down
2 changes: 1 addition & 1 deletion json_demo/json_demo.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

// This demo shows you how to read and write JSON objects and arrays.
Expand Down
2 changes: 1 addition & 1 deletion json_headers_only_demo/json_headers_only_demo.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

// This demo shows you how to read and write JSON objects and arrays
Expand Down
4 changes: 2 additions & 2 deletions json_map_demo/json_map_demo.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

// This demo shows you how to read and write JSON objects and arrays.
Expand Down Expand Up @@ -131,4 +131,4 @@ int main()

return 0;
}
;
;
2 changes: 1 addition & 1 deletion json_spirit/json_spirit.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_spirit/json_spirit_error_position.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_spirit/json_spirit_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#include "json_spirit_reader.h"
Expand Down
2 changes: 1 addition & 1 deletion json_spirit/json_spirit_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_spirit/json_spirit_reader_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_spirit/json_spirit_stream_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_spirit/json_spirit_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_spirit/json_spirit_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This source code can be used for any purpose as long as
this comment is retained. */

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#include "json_spirit_value.h"
2 changes: 1 addition & 1 deletion json_spirit/json_spirit_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_spirit/json_spirit_writer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#include "json_spirit_writer.h"
Expand Down
2 changes: 1 addition & 1 deletion json_spirit/json_spirit_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
4 changes: 3 additions & 1 deletion json_spirit/json_spirit_writer_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand All @@ -28,6 +28,8 @@ namespace json_spirit
always_escape_nonascii = 0x10,
// all unicode wide characters are escaped, i.e. outputed as "\uXXXX", even if they are
// printable under the current locale, ascii printable chars are not escaped
no_quote_strings = 0x20,
// Don't place quotes around strings (useful for writing single values to a stream)
};
}

Expand Down
12 changes: 10 additions & 2 deletions json_spirit/json_spirit_writer_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down Expand Up @@ -177,6 +177,7 @@ namespace json_spirit
, esc_nonascii_( ( options & always_escape_nonascii ) != 0 )
, remove_trailing_zeros_( ( options & remove_trailing_zeros ) != 0 )
, single_line_arrays_( ( options & single_line_arrays ) != 0 )
, no_quote_strings_( ( options & no_quote_strings) != 0 )
, ios_saver_( os )
{
output( value );
Expand Down Expand Up @@ -225,7 +226,13 @@ namespace json_spirit

void output( const String_type& s )
{
os_ << '"' << add_esc_chars( s, raw_utf8_, esc_nonascii_ ) << '"';
if(!no_quote_strings_) {
os_ << '"';
}
os_ << add_esc_chars( s, raw_utf8_, esc_nonascii_ );
if(!no_quote_strings_) {
os_ << '"';
}
}

void output( bool b )
Expand Down Expand Up @@ -352,6 +359,7 @@ namespace json_spirit
bool esc_nonascii_;
bool remove_trailing_zeros_;
bool single_line_arrays_;
bool no_quote_strings_;
boost::io::basic_ios_all_saver< Char_type > ios_saver_; // so that ostream state is reset after control is returned to the caller
};

Expand Down
2 changes: 1 addition & 1 deletion json_test/json_spirit_reader_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#include "json_spirit_reader_test.h"
Expand Down
2 changes: 1 addition & 1 deletion json_test/json_spirit_reader_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_test/json_spirit_stream_reader_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#include "json_spirit_stream_reader_test.h"
Expand Down
2 changes: 1 addition & 1 deletion json_test/json_spirit_stream_reader_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_test/json_spirit_utils_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#include "json_spirit_utils_test.h"
Expand Down
2 changes: 1 addition & 1 deletion json_test/json_spirit_utils_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_test/json_spirit_value_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#include "json_spirit_value_test.h"
Expand Down
2 changes: 1 addition & 1 deletion json_test/json_spirit_value_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_test/json_spirit_writer_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#include "json_spirit_writer_test.h"
Expand Down
2 changes: 1 addition & 1 deletion json_test/json_spirit_writer_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down
2 changes: 1 addition & 1 deletion json_test/json_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#include "json_spirit_value_test.h"
Expand Down
3 changes: 2 additions & 1 deletion json_test/utils_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright John W. Wilkinson 2011
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.06
// json spirit version 4.06.1
// upstream json spirit version 4.06

#include "utils_test.h"

Expand Down
2 changes: 1 addition & 1 deletion json_test/utils_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright John W. Wilkinson 2007 - 2013
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.07
// json spirit version 4.06.1
// upstream json spirit version 4.06

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Expand Down

0 comments on commit 11f6ab3

Please sign in to comment.