Skip to content

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

Closed

Description

@sivapooja

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 + "\"  }";

Activity

  1. nlohmann commented on Aug 9, 2017

    @nlohmann
    Owner

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

  2. sivapooja commented on Aug 9, 2017

    @sivapooja
    Author

    Error message is

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

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

  3. nlohmann commented on Aug 9, 2017

    @nlohmann
    Owner

    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?

  4. nlohmann commented on Aug 10, 2017

    @nlohmann
    Owner

    Any news on this?

  5. nlohmann commented on Aug 14, 2017

    @nlohmann
    Owner

    @sivapooja Any news on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions