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

program crash everytime, when other data type incomming in json stream as expected #1612

Closed
bnadem opened this issue May 28, 2019 · 6 comments
Labels
kind: question state: needs more info the author of the issue needs to provide more details

Comments

@bnadem
Copy link

bnadem commented May 28, 2019

i use this nhlohman in backend , this wonderfull tool, i becomme every second json stream from outside, but when the users send other datatyp in json stream, my backend crash every time, i muss use in every code line try catch, to prevent crash backend, there is no other solution please, thanks

  • Describe what you want to achieve.

  • Describe what you tried.

  • Describe which system (OS, compiler) you are using.

  • Describe which version of the library you are using (release version, develop branch).

@nlohmann
Copy link
Owner

nlohmann commented Jun 1, 2019

Can you provide more information? Maybe example code? The library throws an exception in case of a parse error - is this your issue?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Jun 1, 2019
@bnadem
Copy link
Author

bnadem commented Jun 1, 2019

Yes ihre this auto user_input = j_string.getstd::string();
But user_input is integer, other datatyp but not string
Think for replay

@nlohmann
Copy link
Owner

nlohmann commented Jun 1, 2019

You need to check the types yourself. Code like

std:.string user_input;
if ( j_string.is_string())
    user_input = j;

is safe.

@bnadem
Copy link
Author

bnadem commented Jun 1, 2019

I mean like that: std:string user_input = jsondata("inputdtream").getstd:string().
How I can check inputdstream ist string?

@nlohmann
Copy link
Owner

nlohmann commented Jun 1, 2019

@bnadem
Copy link
Author

bnadem commented Jun 13, 2019

thanks

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
Projects
None yet
Development

No branches or pull requests

2 participants