[Boost-bugs] [Boost C++ Libraries] #9721: ptree write_json does not conform to JSON standard

Subject: [Boost-bugs] [Boost C++ Libraries] #9721: ptree write_json does not conform to JSON standard
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-27 14:52:01


#9721: ptree write_json does not conform to JSON standard
-------------------------------------------+---------------------------
 Reporter: Mark Pfeifer <Mark_Pfeifer@…> | Owner: cornedbee
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: property_tree
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
-------------------------------------------+---------------------------
 According to the JSON standard documented at http://www.json.org, only
 string values should have quotes around them. The Boost write_json method
 puts quotes around all values, not just strings.

 For example, the following program:

 #include <cstdlib>
 #include <string>
 #include <iostream>
 #include <boost/property_tree/ptree.hpp>
 #include <boost/property_tree/json_parser.hpp>

 using boost::property_tree::ptree;
 using boost::property_tree::read_json;
 using boost::property_tree::write_json;

 int main()
 {
     ptree pt;

     pt.put ("string", "string value");
     pt.put ("integer", 1);
     pt.put ("float", 3.14159);

     std::ostringstream buf;
     write_json (buf, pt);

     std::cout << buf.str();
     return 0;
 }

 produces this output:

 {
     "string": "string value",
     "integer": "1",
     "float": "3.14159"
 }

 According to the JSON standard, the output should be:

 {
     "string": "string value",
     "integer": 1,
     "float": 3.14159
 }

 (no quotes around the numeric values)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9721>
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:15 UTC