Skip to content

Help for a Beginner? #2141

Description

@duojet2ez

Hello,

I am trying to make a text based game and had the idea to use a json file to store all of the text for each page. And then I can conveniently turn the text into a json object and in my main.cpp output the text from the json file.

Because I am new (barely figured out how to get this library installed) I am having a hell of a time understanding the documentation. Is my stated objective possible?

The only thing I have figured out how to do is store text in a json file:

{
"text": "goes here"

}

and then in my main.cpp file I call that text by opening and reading into the file:

 std::ifstream inFile("pagetest.json");  
json j; 
inFile >> j; 
std::string s = j.dump(); 
std::cout << s << std::endl; 

However, this does not behave as I'd expect. It outputs everything including the quotations and the {} which is what I don't want. I would need just a string outputted.

Basically I am very confused.... Any help would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions