Commit Graph

8 Commits

Author SHA1 Message Date
Sebastian Redl
b2c488be9b Replace the JSON parser with a new one.
TL;DR: The new parser fixes long-standing bugs and has full Unicode support, but removes non-standard extensions
of the old parser, which could break code:
- String concatenation: the old parser concatenated adjacent string literals like C does.
- Comments: the old parser supported C and C++-style comments. JSON doesn't allow comments.

The JSON writer hasn't been changed; it still has all the Unicode-related problems.

The old JSON parser had quite a few problems:
- Slow to compile.
- Based on the obsolete Spirit.Classic.
- Inherited a multithreading bug from Spirit.Classic (see bug #5520).
- Poor to no support for Unicode.
- Weird departures from standard JSON.
- Tightly bound to string-based property trees.

The new parser has the following features:
- Hand-written recursive descent parser - few template instantiations, fast to compile.
- Parses through a pair of iterators with support for input iterators - can parse directly from streambuf_iterators.
  Doesn't need to load the entire file into memory first.
- Push-based stream model.
- Full support for Unicode. Assumes that char is UTF-8. If wchar_t is 16 bits, assumes UTF-16, with support for surrogate pairs.
- Pluggable encoding support. The public interface doesn't expose this yet. Currently, narrow input streams are assumed to use
  UTF-8 both internally and externally, and wide streams are assumed to use UTF-16 or UTF-32, depending on the bit width of wchar_t.
  Malformed encodings are not accepted.
  The pluggable support allows inserting other external encodings, or making narrow streams parse into wide internal trees, etc.
- Replaceable event handlers. Also not exposed by the public interface, the replaceable event handlers allow parsing into non-string
  property trees and preserving type information of the JSON.
2015-06-26 10:32:29 +02:00
Sebastian Redl
c452635a08 Fix JSON non-ASCII escaping test to work with MSVC. 2015-01-21 12:16:24 +01:00
Berkus Decker
5c26e8d8b2 Add escaping tests. 2014-11-12 20:31:40 +02:00
Sebastian Redl
530e6fe5eb Fix JSON array compact printing.
Fixes bug 7180.

As drive-by fixes, actually test the pretty printer and don't ever
start a new line after a property name.
2014-02-11 16:54:07 +01:00
Sebastian Redl
4d3c2c6998 Allow top-level array in PTree JSON parser, as requested in bug 4387.
[SVN r68992]
2011-02-18 16:29:10 +00:00
Sebastian Redl
935a6567e2 Turns out JSON doesn't allow \0 as an escape sequence. Also, don't rely on is_print for figuring out which characters to escape, but instead follow the spec. Fixes bug 3827.
[SVN r59738]
2010-02-17 18:43:56 +00:00
Jeremiah Willcock
8173d7d5af Fixed more tab and min/max issues
[SVN r53152]
2009-05-21 14:38:00 +00:00
Marcin Kalicinski
f4105f823f Adding property_tree
[SVN r37680]
2007-05-12 22:02:53 +00:00