$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r68992 - in trunk: boost/property_tree/detail libs/property_tree/test
From: sebastian.redl_at_[hidden]
Date: 2011-02-18 11:29:11
Author: cornedbee
Date: 2011-02-18 11:29:10 EST (Fri, 18 Feb 2011)
New Revision: 68992
URL: http://svn.boost.org/trac/boost/changeset/68992
Log:
Allow top-level array in PTree JSON parser, as requested in bug 4387.
Text files modified: 
   trunk/boost/property_tree/detail/json_parser_read.hpp |     4 ++--                                    
   trunk/libs/property_tree/test/test_json_parser.cpp    |     9 +++++++++                               
   2 files changed, 11 insertions(+), 2 deletions(-)
Modified: trunk/boost/property_tree/detail/json_parser_read.hpp
==============================================================================
--- trunk/boost/property_tree/detail/json_parser_read.hpp	(original)
+++ trunk/boost/property_tree/detail/json_parser_read.hpp	2011-02-18 11:29:10 EST (Fri, 18 Feb 2011)
@@ -184,7 +184,7 @@
                 using boost::spirit::classic::assertion;
 
                 // Assertions
-                assertion<std::string> expect_object("expected object");
+                assertion<std::string> expect_root("expected object or array");
                 assertion<std::string> expect_eoi("expected end of input");
                 assertion<std::string> expect_objclose("expected ',' or '}'");
                 assertion<std::string> expect_arrclose("expected ',' or ']'");
@@ -195,7 +195,7 @@
 
                 // JSON grammar rules
                 root 
-                    =   expect_object(object) 
+                    =   expect_root(object | array) 
                         >> expect_eoi(end_p)
                         ;
                 
Modified: trunk/libs/property_tree/test/test_json_parser.cpp
==============================================================================
--- trunk/libs/property_tree/test/test_json_parser.cpp	(original)
+++ trunk/libs/property_tree/test/test_json_parser.cpp	2011-02-18 11:29:10 EST (Fri, 18 Feb 2011)
@@ -249,6 +249,9 @@
 const char *error_data_4 = 
     "{\n\"a\"\n}";      // No object
 
+const char *bug_data_pr4387 =
+    "[1, 2, 3]"; // Root array
+
 struct ReadFunc
 {
     template<class Ptree>
@@ -369,6 +372,12 @@
         "testerr4.json", NULL, "testerr4out.json", 3
     );
 
+    generic_parser_test_ok<Ptree, ReadFunc, WriteFunc>
+    (
+        ReadFunc(), WriteFunc(), bug_data_pr4387, NULL, 
+        "testpr4387.json", NULL, "testpr4387out.json", 4, 3, 0
+    );
+
 }
 
 int test_main(int argc, char *argv[])