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

Parse error while parse the json string contains UTF 8 encoded document bytes string #684

Closed
sivapooja opened this issue Aug 9, 2017 · 5 comments

Comments

@sivapooja
Copy link

sivapooja commented Aug 9, 2017

Hi,
I am sending json string with UTF 8 encoded document bytees string from asp.net and receiving the json from c++ program , i am getting parse error while trying to parse the received json string to json object

        string jsonStr = string( body.begin(), body.end() );               
         json j = json::parse(jsonStr);

Asp.net Json string

string docBytesStr = System.Text.Encoding.UTF8.GetString(docBytes, 0, docBytes.Length);
string jsonData = "{ \"template\" : \"1\", \"doc\":\"" + docBytesStr + "\"  }";
@nlohmann
Copy link
Owner

nlohmann commented Aug 9, 2017

Could you post the error message and the exact content of jsonStr?

@sivapooja
Copy link
Author

Error message is

std::invalid_argument'
what(): parse error - unexpected '"'

the json string is very large because it contains the document byte string

@nlohmann
Copy link
Owner

nlohmann commented Aug 9, 2017

The error message indicates that there is a JSON syntax error due to an unexpected quote character. Maybe docBytesStr contains a string with an unescaped quote? Can you validate that the string you pass to parse is valid JSON?

@nlohmann
Copy link
Owner

Any news on this?

@nlohmann nlohmann added the state: please discuss please discuss the issue or vote for your favorite option label Aug 10, 2017
@nlohmann
Copy link
Owner

@sivapooja Any news on this?

@nlohmann nlohmann removed the state: please discuss please discuss the issue or vote for your favorite option label Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants