Skip to content

[Proposal] Decide based on JSONParserConfiguration, If a field can be ignored while creating JSONObject from Object type #982

@harshith8854

Description

@harshith8854

Hi,

I have a scenario where we are creating a JSONObject for a MAP and there is a possiblity of values being instances of custom class types with no fields initialized. We expect the fields to be retained in JSONObject which is not happening currently. I could think the below line is the reason for the uninitialized fields being ignored.

if (result != null) {

It would be good to consider JSONParserConfiguration.isUseNativeNulls() to decide if the fields can be ignored, just as implemented at below line.
https://github.com/stleary/JSON-java/blob/master/src/main/java/org/json/JSONObject.java#L335

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions