How to use json-spirit to read json string in C++? I read the demo code. I find that:
const Address addrs[5] = { { 42, "East Street", "Newtown", "Essex", "England" },
{ 1, "West Street", "Hull", "Yorkshire", "England" },
{ 12, "South Road", "Aberystwyth", "Dyfed", "Wales" },
{ 45, "North Road", "Paignton", "Devon", "England" },
{ 78, "Upper Street", "Ware", "Hertfordshire", "England" } };
Can I convert a String into a json object?
char* jsonStr = "{'name', 'Tom'}";
json_spirit provides
bool read_string( const String_type& s, Value_type& value )
andbool read( const std::string& s, Value& value )
to read json data from strings.Here is an example:
You could also use ifstream instead of string to read from json from file.
Please note, according to RFC4627 a string begins and ends with quotation marks.