.get<std::string> causing emdash errors
Not a very experienced programmer, but I've been putting together a small project using json files and encountered some issues with printing values from json. My code contains a number of conditionals similar to below, which are supposed to print out the value associated with a given key in a much larger json file. In this case, "type" is a key with an associated string value. However, when I run the program, the code prints out a small pile of random Unicode symbols instead of what's written in the json file. Is this something that is solvable, or is something wrong on my end?
if (unique.find("type") != unique.end()) {
cout << unique["type"].get<std::string>() << endl;
}
Expected: Creature — Cat
Actual: Creature ΓÇö Cat
I've been building my code on Windows using Visual Studio 2019 16.3.10, and am currently using nlohmann json version 3.7.3.
Thanks, Julian Lane.
How does the JSON value look like? What is the output of unique.dump()?
Hadn't thought about dumping the json values yet, but the dump resulted in the same errors. I attached both the correct text form of the json and the dumped version for further troubleshooting.
Both files look good. Please provide the code you use to read/create the value and the exact error message.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.