-
Notifications
You must be signed in to change notification settings - Fork 2
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
JsonPointer syntax errors should not be valid #2
Comments
@ssilverman |
Yes. I’ve also got a new validator and was glad to have found yours too a while back. |
@ssilverman The purpose of this test suite is to test implementations of JSR 374 (JSON Processing) API, The JSON-P specification tells us that JSON Pointer in JSON-P should conform to
Therefore we should respect of the behavior of the Reference Implementation. You are almost correct. I once implemented my parser to throw exceptions in such cases, but I changed it in order to conform to the Reference Implementation. |
@ssilverman |
I hear you on the point about the tests not being to test JSON nor to test the JSON-P API, it's to test the implementation of the JSON-P API. However, what happens if the implementation disagrees with its own documentation? JSON-P specifically states, in @throws JsonException if {@code jsonPointer} is not a valid JSON Pointer It also states in RFC 6901 (https://www.rfc-editor.org/rfc/rfc6901.html#section-3)
While I agree that the RFC leaves it up to the application to handle errors, the API itself states that a So back to the first question in this post: What happens if the implementation disagrees with its own documentation? In this case the JSON-P API itself stating an exception should be thrown? |
@ssilverman But I cannot say this is a bug with 100% confidence. Apache Johnzon also does not throw an exception in this case. So I judged these test cases are valid and I modified Joy (my own implementation) in order to be compatible with other implementations. If you are sure that this is a bug in the Reference Implementation, I recommend you consult this problem with JSON-P team. |
@ssilverman |
I built my own parser (I'm not wrapping anything) and thought I'd code it to a well-known Java spec because I like it when things are compatible; I found It all started when I was tasked with doing some RDM standards work (DMX related; lighting control and such) related to JSON schemas (rabbit hole # 1). Because no Java implementation yet implemented Draft 2019-09, I wrote one (rabbit hole # 2). Then, I went down another rabbit hole with how to effectively do proper errors and annotations such that they're not only clear, but organized well and only giving information instead of too much when there's just simple errors in a schema instance (rabbit hole # 3). I needed a break from that, remembered that I like writing manual DFA-based parsers (deterministic finite automaton), so I wrote a DFA (in truth a PDA (pushdown automaton) because it kind of needs a stack) for all the character transition states in JSON (actually, I implemented complete JSON5 support) thinking it would be as fast as possible (basically one table lookup per character read, plus another table lookup for an associated action, plus a little additional logic) (rabbit hole # 4). As I said, I like standards and compatible interfaces, so I completed a So, in summary: an attempt at a faster JSON parser, and "completeness". |
@ssilverman |
<sigh> My implementation looks like it's 4x ops/s slower than the reference implementation. I must be doing something that's not very JIT friendly. |
@ssilverman |
jsonp-test-suite/src/main/java/org/leadpony/jsonp/testsuite/tests/JsonPointerTest.java
Lines 68 to 70 in 6dca31b
These should be
false
since their syntax is invalid.The text was updated successfully, but these errors were encountered: