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

JSONObject#getString() returns a string literal - "null" instead of null when the value is null #5

Closed
yusuke opened this issue Dec 28, 2010 · 3 comments

Comments

@yusuke
Copy link

yusuke commented Dec 28, 2010

This test case fails:

public void testNull() throws Exception {
    JSONObject j;

    j = new JSONObject("{\"message\":\"null\"}");
    assertFalse(j.isNull("message"));
    assertEquals("null", j.getString("message"));

    j = new JSONObject("{\"message\":null}");
    assertTrue(j.isNull("message"));
    assertEquals(null, j.getString("message")); // fail here: getString should return null instead of "null"
}

@douglascrockford
Copy link
Contributor

Thanks.

@mjb-starleaf
Copy link

Was this issue fixed? If not, will it be? It's a correctness issue.

@stleary
Copy link
Owner

stleary commented Sep 13, 2021

@mjb-starleaf This issue should have been fixed. Parsing a JSON doc with null as an object value should store a JSONObject.Null instance for the null value.

stleary pushed a commit that referenced this issue Oct 17, 2023
…JSONObjectTest#valueToString

fix: flakiness in org.json.junit.JSONObjectTest#valueToString
This issue was closed.
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

4 participants