Skip to content

Parse error with json containing several key/value structures #2919

Answered by edu-arr99
edu-arr99 asked this question in Q&A
Discussion options

You must be logged in to vote

Just in case anyone needs it, I found a solution:

void Parser::readJSON() {
    ifstream file(this->path, ifstream::in);        // open file
    string line, jsonString;
    while (getline(file, line))                     // we pass the json info into a string first
        jsonString += line + "\n";
    
    this->jsonGraph = json::parse(jsonString);            // we parse from the string
}

I replaced the global curly braces for square brackets in the json file, and managed to make it work this way.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@gregmarr
Comment options

@edu-arr99
Comment options

Answer selected by edu-arr99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants