Closed glyn closed 2 years ago
It depends. For example, the APIs of some JSONPath implementations take a rich type which represents a valid JSON value. In that case, handling invalid JSON happens before the API is called and is not a concern of the API. But other implementations could have an API which takes a string, which may or may not represent valid JSON.
So, to be clear, we probably need some words in the spec which says the spec does not prescribe how invalid JSON is handled. This is better than silence.
Or we could require that invalid JSON cannot result in a non-empty nodelist from a JSONPath query.
@timbray
I don't see anything in the draft spec about what happens if you try to apply a JSONPath and what you're trying to apply it to is broken
But "brokenness" would apply to JSON texts, wouldn't it? As @cabo noted in (https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/pull/223#issuecomment-1184361289), "JSON text is a sequence of characters, an unparsed piece of JSON for interchange, with newlines and backslashes and all that. JSONPath never looks at JSON texts. JSON value is the RFC 8259 term for what JSONPath looks at."
The parser would care about "broken" JSON texts, but JSONPath should never see them.
Agree with last two points. The spec describes the application of a JSONPath expression to parsed JSON, so JSON texts are out-of-scope. As @glyn says, we should make that explicit.
JSON Schema simply defines that it operates on the JSON data model.
JSON Schema interprets documents according to a data model.
This section covers a range of issues that we've found in our history, including handling whitespace differences, duplicate keys, etc.
I think this is a great approach.
@timbray wrote: