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

Double quotation mark is not parsed correctly #60

Closed
miloyip opened this issue Apr 19, 2015 · 3 comments
Closed

Double quotation mark is not parsed correctly #60

miloyip opened this issue Apr 19, 2015 · 3 comments
Assignees

Comments

@miloyip
Copy link

miloyip commented Apr 19, 2015

In JSON, double quotation mark in a JSON string is escaped as \", such as

["\"foo\""]

should be escaped as "foo". But this library did not handle it and parsed it as \"foo\".

I reproduced the bug with the following test case:

    SECTION("escape_dobulequote")
    {
        auto s = "[\"\\\"foo\\\"\"]";
        json j = json::parse(s);
        CHECK(j == json({"\"foo\""}));
    }

Results:

test/unit.cpp:6351: FAILED:
  CHECK( j == json({"\"foo\""}) )
with expansion:
  ["\\\"foo\\\""] == "\"foo\""
@miloyip miloyip changed the title Double quotation mark is not escaped correctly Double quotation mark is not parsed correctly Apr 19, 2015
@jgod
Copy link

jgod commented Apr 21, 2015

👍 I noticed this too. I've been manually escaping my strings

@nlohmann nlohmann self-assigned this Apr 21, 2015
@nlohmann
Copy link
Owner

The problem is the escape_string function that seems to escape strings to strictly. I would be glad about help how to improve the function.

@nlohmann
Copy link
Owner

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

No branches or pull requests

3 participants