'libc++abi: terminating with uncaught exception of type Json::RuntimeError: * Line 1, Column 1 Syntax error: value, object or array expected

I am trying to get data from my json document into my main.cpp using Jsoncpp. I am getting this error message :

libc++abi: terminating with uncaught exception of type Json::RuntimeError: * Line 1, Column 1 Syntax error: value, object or array expected.

Here is how I'm passing the data on my main.cpp :

ifstream file("calibration1114.json");
Json::Value root;
file >> root;

string s = root["sensitivity"].asString();

cout << s << endl

Here is my Json file :

{"fileName":"2021-08-19T14:40:24-04:00",

"differencedB":-0.02,

"sensitivity":"74.5758204562815678",

"date":"2021-08-19T14:40:24-04:00"}

I have also trying parsing data this way on my main.cpp :

ifstream file("calibration1114.json");
Json::Value root;
Json::Reader reader;

bool parsingSuccessful = reader.parse( file, root );
   if ( !parsingSuccessful )
   {
       cout << "Error parsing the string" << endl;
   }
reader.parse( file, actualJson);

string s = root["sensitivity"].asString();

cout << s << endl;

The "Error parsing the string" message shows up. Thank you for the help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source