Index: boost/property_tree/detail/json_parser_write.hpp =================================================================== --- boost/property_tree/detail/json_parser_write.hpp (revision 86799) +++ boost/property_tree/detail/json_parser_write.hpp (working copy) @@ -75,9 +75,45 @@ if (indent > 0 && pt.empty()) { // Write value - Str data = create_escapes(pt.template get_value()); - stream << Ch('"') << data << Ch('"'); - + Str str_data = create_escapes(pt.template get_value()); + bool written = false; + if (!written) + { + if (str_data == "true" || str_data == "false") + { + stream << str_data; + written = true; + } + } + if (!written) + { + try + { + int data = pt.template get_value(); + stream << data; + written = true; + } + catch (...) + {} + } + if (!written) + { + try + { + double data = pt.template get_value(); + stream << data; + written = true; + } + catch (...) + {} + } + if (!written) + { + if (str_data == "null") + stream << "null"; + else + stream << Ch('"') << str_data << Ch('"'); + } } else if (indent > 0 && pt.count(Str()) == pt.size()) { @@ -159,6 +195,11 @@ { if (!verify_json(pt, 0)) BOOST_PROPERTY_TREE_THROW(json_parser_error("ptree contains data that cannot be represented in JSON format", filename, 0)); + + stream.setf(std::ios::fixed, std::ios::floatfield); + stream.setf(std::ios::showpoint); + stream.precision(std::numeric_limits::digits10 + 1); + write_json_helper(stream, pt, 0, pretty); stream << std::endl; if (!stream.good())