Reputation: 155
When reading the below JSON data, am getting invalid code sequence exception in read_json.
{
"_ID":"18",
"_Record":"1",
"_BreakPageMessage":"abcd: 137
Product: ID: 1234
Description: 23456 abcdfm
CustomerId: 23456
Component Id: 3456
Description: 12345 Admn RC - up
count: 40
Sides 2
Tarnish:
size: 125 x 205
Memo:"
}
_BreakPageMessage property has multiple lines. If we give it as single line everything works fine. This _BreakPageMessage doesn't have any umlaut characters.
boost::property_tree::read_json( file, pt );
Can anyone tell is there anyway to read json that has multiple lines of property data using boost.We are using C++ and boost.
Upvotes: 0
Views: 138
Reputation: 62684
Newlines are not valid characters in JSON strings, your data isn't JSON.
You could escape them
{
"_ID":"18",
"_Record":"1",
"_BreakPageMessage":"abcd: 137\r\n Product: ID: 1234\r\n Description: 23456 abcdfm\r\n CustomerId: 23456\r\n Component Id: 3456\r\n Description: 12345 Admn RC - up\r\n count: 40\r\n Sides 2\r\n Tarnish:\r\n size: 125 x 205\r\n Memo:"
}
or use a sub-object
{
"_ID":"18",
"_Record":"1",
"_BreakPageMessage":{
"abcd": 137,
"Product": { "ID": 1234 },
"Description": "23456 abcdfm",
"CustomerId": "23456",
"Component Id": "3456",
"Description": "12345 Admn RC - up",
"count": "40",
"Sides": "2",
"Tarnish": { size: "125 x 205" },
"Memo":""
}
}
Upvotes: 2