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

Empty string parses as null string #17

Open
Mzyxptlk opened this issue Oct 22, 2012 · 3 comments
Open

Empty string parses as null string #17

Mzyxptlk opened this issue Oct 22, 2012 · 3 comments

Comments

@Mzyxptlk
Copy link

{
    "action":"EntityHandler",
    "method":"updateParameter",
    "data": [
        "/path/name",
        "text",
        ""
    ],
    "type":"rpc",
    "tid":294
}

When parsed, "" becomes a null QString, as opposed to an empty QString. The difference is significant. This seems to be an issue in Json::parseString, where the initial result string is created as QString s, rather than QString s("") or QString s = "".

@martinrotter
Copy link
Contributor

Well, this issue report is invalid, since QString("") and QString() are BOTH empty strings + QString() is null string in the same time.

External representation of both strings is "", thus behavior of qt-json is correct.

@Mzyxptlk
Copy link
Author

It just took me about 15 minutes to understand my own bug report, so clearly I did a bad job explaining the issue. Here's another try.

Currently, both JSON null and JSON "" become QString(). QString() is both empty and null, as martinrotter said, but that is exactly the problem: JSON "" is not identical to JSON null, so why are they represented by the same value in qt-json?

If Json::parseString initialized its return value as QString s(""), then JSON "" would still be empty, but no longer null. This is the correct behaviour. It allows you to distinguish between JSON null and JSON "", whereas the current implementation does not.

@martinrotter
Copy link
Contributor

IC. So then this bug report is indeed valid and could be fixed the way Mzyxptlk wrote in the first message.

@gaudecker gaudecker reopened this Jan 30, 2014
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