-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
"type must be string, but is " std::string(j.type_name() #1206
Comments
Can you show your JSON file and all the code from read to the exception? |
I assume that If not, then default constructed json values are |
@kenshen112 There is no |
@gregmarr The createEnemy and init function is the JSON libaray code @theodelrieu By initalized do you mean set to NULL or the JSON library equivilent? IE. JSON J = NULL or nullptr. |
Ah, I see, the |
One last question it's giving me a Syntax error where there should be none |
I would start by removing all whitespace from the file. You might have an invisible control character somewhere. |
Didn't work (Quick Edit) Turns out it is reading the entire file, I tried printing out the Name variable and all three appear so the error must be referring to the end of the file. |
@kenshen112 I am confused. Did #1206 (comment) solve your issue or is there anything left open? |
@nlohmann It did but it brought another issue that I have yet to solve that i asked shortly after that |
You mean the parse error? Could you share the JSON text and the code with which you parse it? |
What is the exact error message? |
That said I can see the name var printing out in the console perfectly for all three and no matter the adjustments I make to the file the error never vanishes not that it'd matter the file itself is valid |
The exception should contain a position of the error. |
|
Can you parse the file in like this: std::ifstream f("yourfile.json);
json j = json::parse(f); ? |
It gave me the same error but this time it didn't print the name data like it was before |
Are you sure you opened the file correctly? And all parse errors contain the position like
If you have a |
Got it figured out, had to change the design of the parsing function it was indeed the while loop that was messing it all up thanks for the help! |
What is the issue you have? JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name())));
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
Create a JSON file with multiple objects and attempt to iterate with ` assert(baddie.is_array());
What is the expected behavior?
The file is properly read and parsed.
And what is the actual behavior instead?
it gives the error above and an exception
Unhandled exception at 0x00007FFF278EB098 in rpg.exe: Microsoft C++ exception: nlohmann::detail::type_error at memory location 0x000000268ECFF168. occurred
Visual Studio 2017
develop
branch?From release.
Also this is for an entirely different project the solution for the question I posted worked perfectly.
The text was updated successfully, but these errors were encountered: