Итак, я недавно установил JSONCPP и по какой-то причине он выдает ошибки при попытке этого кода:
#include <json.h>
#include <iostream>
#include <fstream>
int main(){
bool alive = true;
while (alive){
Json::Value root; // will contains the root value after parsing.
Json::Reader reader;
std::string test = "testis.json";
bool parsingSuccessful = reader.parse( test, root, false );
if ( !parsingSuccessful )
{
// report to the user the failure and their locations in the document.
std::cout << reader.getFormatedErrorMessages()
<< "\n";
}
std::string encoding = root.get("encoding", "UTF-8" ).asString();
std::cout << encoding << "\n";
alive = false;
}
return 0;
}
А вот и файл:
{
"encoding" : "lab"
}
В нем говорится, что в строке 1, столбце 1 есть синтаксическая ошибка и что должно быть значение, объект или массив. Кто-нибудь знает, как это исправить?
РЕДАКТИРОВАТЬ: изменен на текущий код, с pastebin