Skip to content

Inconsistent null Handling Across JSONObject Construction Paths #1049

@venkat-cheenu

Description

@venkat-cheenu

Jar version : json-20251224.jar

Reproduction :

// String constructor — null preserved
new JSONObject("{\"name\":null}");         // {"name":null}

// Map constructor — null dropped
Map<Object, Object> map = new HashMap<>();
map.put("name", null);
new JSONObject(map);                       // {}

// put() — null dropped
JSONObject json = new JSONObject();
json.put("name", (String) null);           // {}

Expected :
All construction paths should treat null consistently. Per the JSON spec (RFC 8259), null is a valid value and should be retained.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions