Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.get<std::string> causing emdash errors #2180

Closed
poi2000 opened this issue Jun 9, 2020 · 4 comments
Closed

.get<std::string> causing emdash errors #2180

poi2000 opened this issue Jun 9, 2020 · 4 comments
Labels
kind: question state: needs more info the author of the issue needs to provide more details state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated

Comments

@poi2000
Copy link

poi2000 commented Jun 9, 2020

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.

@nlohmann
Copy link
Owner

nlohmann commented Jun 9, 2020

How does the JSON value look like? What is the output of unique.dump()?

@nlohmann nlohmann added state: needs more info the author of the issue needs to provide more details kind: question and removed kind: bug labels Jun 9, 2020
@poi2000
Copy link
Author

poi2000 commented Jun 9, 2020

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.

unique_dump.txt
unique_plaintext_json.txt

@nlohmann
Copy link
Owner

nlohmann commented Jun 9, 2020

Both files look good. Please provide the code you use to read/create the value and the exact error message.

@stale
Copy link

stale bot commented Jul 11, 2020

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.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question state: needs more info the author of the issue needs to provide more details state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated
Projects
None yet
Development

No branches or pull requests

2 participants