Subject: [Boost-bugs] [Boost C++ Libraries] #3827: Embeded null written as \0 rather than \u0000 in property_tree::write_json
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-01-07 23:58:21
#3827: Embeded null written as \0 rather than \u0000 in property_tree::write_json
-----------------------------------------------------+----------------------
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: |
-----------------------------------------------------+----------------------
Here's an example
{{{
#include "boost/property_tree/json_parser.hpp"
#include "boost/array.hpp"
int main()
{
boost::property_tree::ptree pt;
// Some random data to encode
boost::array<unsigned char, 8> data = { 3,0,'W','A',0,'M',255,'z' };
pt.put("binary", std::string(data.begin(), data.end() ) );
boost::property_tree::write_json(std::cout, pt );
}
}}}
This produces the output
{{{
{
"binary": "\u0003\0WA\0M\uFFFFz"
}
}}}
but from the description of JSON strings at http://www.json.org/
and the more detailed version at http://www.ietf.org/rfc/rfc4627.txt
it would appear that the correct encoding of the 0 character is
\u00000 rather than \0 ( which is correctly handled for other non-
prinatable characters. )
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3827> 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