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

Nulls are getting treated as Strings #1

Open
jordanburke opened this issue Feb 7, 2014 · 3 comments
Open

Nulls are getting treated as Strings #1

jordanburke opened this issue Feb 7, 2014 · 3 comments

Comments

@jordanburke
Copy link

First of thanks for wrapping this for CN1. Been using it quite a bit and it's a pretty good lib.

I found an issue I didn't see until today. JSONObject ToString conversion causes nulls to be wrapped with double quotes causing them to treated as strings. I'll submit a patch if I get my env set up otherwise wanted to let you know.

@jordanburke
Copy link
Author

Adding a Null object check like this or similar to the valueToString method:

        if (value instanceof Null) {
            return value.toString();
        }

Fixes the issue for me. Right now it falls to the end where it gets "quoted".

@shannah
Copy link
Owner

shannah commented Feb 7, 2014

Thanks. Can you post a sample JSON string that fails, to demonstrate the problem?

@ramsestom
Copy link

Issue still active...

If you have a json object like:

{"key":null, "key2":"something"}

Reading it and calling the toString() method on the resulting JSONObject would produce this output:

{"key":"null", "key2":"something"}

So null is now wrapped with " and considered as a String value, wich is an issue.

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

3 participants