Hi all,

I experience a strange behavior of parsing non-JSON data with JSON parser. I can create a property_tree from a simple non-JSON string, without exception. And serializing back the result throws :

boost::property_tree::ptree m_tree;
// Non-JSON to ptree using JSON parser
std::istringstream is("1"); // Simple value, non-JSON
boost::property_tree::json_parser::read_json(is, m_tree); // ==> No exception, I now have a valid ptree object.

// ptree back to JSON
std::ostringstream buf;
boost::property_tree::json_parser::write_json(buf, m_tree, false); // ==> Exception

How can I filter input values that will not be serializable later (= verify that input value is well JSON formatted) ?

Thanks for your help,
S. Gallou