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

JSON escape quotes #574

Closed
RedLens834 opened this issue May 5, 2017 · 4 comments
Closed

JSON escape quotes #574

RedLens834 opened this issue May 5, 2017 · 4 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@RedLens834
Copy link

RedLens834 commented May 5, 2017

Hi,

I'm getting JSON from PHP server with curl and I save it to a std::string variable.
So :
std::cout << input;
// {"error":"params problem","vector":"A5+myu8a5QW7Gk98mWws7A=="}

I'd like to deserialize this into a JSON object by doing :
json decodedJson(input)
But here when I make a print of input.dump(4) I'm getting just an escaped string of input.

So I tried a different way :
json decodedJson = json::parse(readBuffer);
And here I have this following error :
libc++abi.dylib: terminating with uncaught exception of type nlohmann::detail::parse_error: [json.exception.parse_error.101] parse error at 1: parse error - unexpected '?'

Is it normal ?
Thanks

@nlohmann
Copy link
Owner

nlohmann commented May 5, 2017

This indicates a parse error in the first byte. The '?' looks as if there is an unexpected control character without proper ASCII representation. Could you check whether the readBuffer is valid JSON?

@RedLens834
Copy link
Author

Yes, readBuffer in my case is input. So it's
{"error":"params problem","vector":"A5+myu8a5QW7Gk98mWws7A=="}, a valid JSON

@nlohmann
Copy link
Owner

nlohmann commented May 5, 2017

Do you set the value yourself or do you receive it from another system? Could you check whether input[0] is really {?

@RedLens834
Copy link
Author

How damm, yes you right ! By doing std::cout << input[0] I saw ?. So I have a bad response from the server. I test that now and I come back to you.
Thanks for your help nlohmann and great work for your plugin !

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label May 5, 2017
@nlohmann nlohmann closed this as completed May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants