Ticket #9496: boost_property_tree_json.patch
File boost_property_tree_json.patch, 2.2 KB (added by , 9 years ago) |
---|
-
boost/property_tree/detail/json_parser_write.hpp
75 75 if (indent > 0 && pt.empty()) 76 76 { 77 77 // Write value 78 Str data = create_escapes(pt.template get_value<Str>()); 79 stream << Ch('"') << data << Ch('"'); 80 78 Str str_data = create_escapes(pt.template get_value<Str>()); 79 bool written = false; 80 if (!written) 81 { 82 if (str_data == "true" || str_data == "false") 83 { 84 stream << str_data; 85 written = true; 86 } 87 } 88 if (!written) 89 { 90 try 91 { 92 int data = pt.template get_value<int>(); 93 stream << data; 94 written = true; 95 } 96 catch (...) 97 {} 98 } 99 if (!written) 100 { 101 try 102 { 103 double data = pt.template get_value<double>(); 104 stream << data; 105 written = true; 106 } 107 catch (...) 108 {} 109 } 110 if (!written) 111 { 112 if (str_data == "null") 113 stream << "null"; 114 else 115 stream << Ch('"') << str_data << Ch('"'); 116 } 81 117 } 82 118 else if (indent > 0 && pt.count(Str()) == pt.size()) 83 119 { … … 159 195 { 160 196 if (!verify_json(pt, 0)) 161 197 BOOST_PROPERTY_TREE_THROW(json_parser_error("ptree contains data that cannot be represented in JSON format", filename, 0)); 198 199 stream.setf(std::ios::fixed, std::ios::floatfield); 200 stream.setf(std::ios::showpoint); 201 stream.precision(std::numeric_limits<double>::digits10 + 1); 202 162 203 write_json_helper(stream, pt, 0, pretty); 163 204 stream << std::endl; 164 205 if (!stream.good())