[Boost-bugs] [Boost C++ Libraries] #3831: property_tree::read_json unable to handle large integers.

Subject: [Boost-bugs] [Boost C++ Libraries] #3831: property_tree::read_json unable to handle large integers.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-01-09 11:32:57


#3831: property_tree::read_json unable to handle large integers.
-----------------------------------------------------+----------------------
 Reporter: Michael Anderson <drmikeando@…> | Owner: cornedbee
     Type: Bugs | Status: new
Milestone: Boost 1.42.0 | Component: property_tree
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
-----------------------------------------------------+----------------------
 Trying to read json that contains a value outside the range of an int into
 a property tree produces the following error
 {{{
 terminate called after throwing an instance of
 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::property_tree::json_parser::json_parser_error>
>'
   what(): <unspecified file>(1): expected value
 }}}

 This is due to the use of a int_p parser in the spirit parsing code.
 Applying the following patch
 {{{
 Index: boost/property_tree/detail/json_parser_read.hpp
 ===================================================================
 --- boost/property_tree/detail/json_parser_read.hpp (revision 58794)
 +++ boost/property_tree/detail/json_parser_read.hpp (working copy)
 @@ -233,7 +233,7 @@

                  number
                      = strict_real_p
 - | int_p
 + | ( ! ( (ch_p('+') | ch_p('-') ) ) ) >> *digit_p
                          ;

                  string
 }}}
 Seems to fix this.

 The following example demonstrates the issue.
 {{{
 #include "boost/property_tree/json_parser.hpp"
 #include "boost/property_tree/info_parser.hpp"

 int main()
 {
   boost::property_tree::ptree pt;
   std::string
 s("{\"v1\":124567890123,\"v2\":+124567890123,\"v3\":-124567890123}");
   std::stringstream ss;
   ss<<s;
   boost::property_tree::read_json( ss, pt );
   boost::property_tree::write_json( std::cout, pt );
 }
 }}}
 This outputs
 {{{
 {
     "v1": "124567890123",
     "v2": "+124567890123",
     "v3": "-124567890123"
 }
 }}}
 When the patch is applied.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3831>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC