Hi all,

I experience a strange behavior of parsing non-JSON data with JSON parser. Take this example :

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 !

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

Unserializing non-JSON value using JSON parser doesn't raise exception.
If you try to serialize the resulted ptree, you now got an exception.

Is this behavior normal ?

In this case, is there an easy and light mean to check that input value is JSON formatted (Regex ?) ?

Thanks for your help,
S. Gallou