ptree json parser is not bidirectionnal
25 Mar
2016
25 Mar
'16
7:28 a.m.
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 parserstd::istringstream is("1"); // Simple value, non-JSON boost::property_tree::json_parser::read_json(is, m_tree); // ==> No exception ! // ptree back to JSONstd::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
3168
Age (days ago)
3168
Last active (days ago)
0 comments
1 participants
participants (1)
-
Sébastien Gallou