Boost C++ Libraries: Ticket #3831: property_tree::read_json unable to handle large integers. https://svn.boost.org/trac10/ticket/3831 <p> Trying to read json that contains a value outside the range of an int into a property tree produces the following error </p> <pre class="wiki">terminate called after throwing an instance of 'boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::property_tree::json_parser::json_parser_error&gt; &gt;' what(): &lt;unspecified file&gt;(1): expected value </pre><p> This is due to the use of a int_p parser in the spirit parsing code. Applying the following patch </p> <pre class="wiki">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('-') ) ) ) &gt;&gt; *digit_p ; string </pre><p> Seems to fix this. </p> <p> The following example demonstrates the issue. </p> <pre class="wiki">#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&lt;&lt;s; boost::property_tree::read_json( ss, pt ); boost::property_tree::write_json( std::cout, pt ); } </pre><p> This outputs </p> <pre class="wiki">{ "v1": "124567890123", "v2": "+124567890123", "v3": "-124567890123" } </pre><p> When the patch is applied. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3831 Trac 1.4.3 Sebastian Redl Wed, 17 Feb 2010 19:26:54 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3831#comment:1 https://svn.boost.org/trac10/ticket/3831#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/59740" title="Make the JSON parser's number production fit the JSON spec instead of ...">[59740]</a>) Make the JSON parser's number production fit the JSON spec instead of doing stupid things. Fixes bug 3831. </p> Ticket Marshall Clow Wed, 18 May 2011 23:02:17 GMT <link>https://svn.boost.org/trac10/ticket/3831#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3831#comment:2</guid> <description> <p> This fix was copied to the release branch in <a class="changeset" href="https://svn.boost.org/trac10/changeset/65975" title="Merge long-overdue PTree changes to release (boost)">[65975]</a>, and was part of boost 1.45.0 </p> </description> <category>Ticket</category> </item> </channel> </rss>