Skip to content

JSONPointer should not always throw JSONPointerException  #233

Closed
@stleary

Description

@stleary

A user may want to evaluate a JSONPointer which is not expected to match the document. For example, when writing a test case to confirm that a specified item is not present. Having to catch exceptions makes this more difficult. It might be better if the JSONPointer query were to return null instead. I don't think there is a conflict with actual null values, since I believe they are stored as JSONObject.NULL.

Certain other cases may justify throwing an exception. For example, using a syntactically incorrect JSONPointer string.

I don't think the spec requires exceptions to be thrown, nor does it seem to require the same behavior for all types of errors.

All of the cases where JSONPointer throws an exception should be evaluated to determine if returning null might be better. Compatibility of JSONPointer returning null and JSONObject.NULL content should be confirmed.

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