RFC 8259 Validation & Compliance #159
-
Is this library 100% compliant with the JSON specification (RFC 8259)? Can this library be used as a document validator for that specification? Is the JSON produced by this library 100% compliant with that specification? I was planning to use simdjson before I realized I can't create JSON documents with it (at least I didn't see how). One big reason I wanted to use simdjson was that it is 100% compliant with RFC 8259 and can validate documents for compliance (i.e. it will reject documents that are not compliant). Just wondering if this library can be used for that purpose as well as creating compliant JSON documents. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
We are aiming for 100% compliance, but we aren't quite there yet. For example, we currently support comments (/**/ and //) when reading. We can easily add a compile time option to turn this off, but it doesn't exist yet. Currently the library uses exceptions for error handling, which isn't ideal for validation. However, we are actively working on updating the codebase to not throw exceptions and instead return error codes and provide error context. This will be a better approach to validation, since exception handling can be slow. We'll keep this issue open until we achieve this goal. I wouldn't recommend using it for validation until the error handling has been updated. Thanks for your question and giving even more reasons for our planned changes. |
Beta Was this translation helpful? Give feedback.
-
Is this library 100% compliant with the JSON specification (RFC 8259)? Is the JSON produced by this library 100% compliant with that specification? Can this library be used as a document validator for that specification? |
Beta Was this translation helpful? Give feedback.
-
Validation and conformance updates were made in #156. Writing should be 100% compliant and reading should be 100% compliant when using the force_conformance option. We cant guarantee this but we have added a bunch of new conformance tests and any conformance issue reported will be treated as a bug. A validate_json convivence function was added std::string fail10 = R"({"Extra value after close": true} "misplaced quoted value")";
assert(glz::validate_json(fail10) != glz::error_code::none); This essentially just calls glz::read<glz::opts{.force_conformance = true}> on the input buffer with a glz::skip My personal opinions on spec conformance:
Edit: |
Beta Was this translation helpful? Give feedback.
Validation and conformance updates were made in #156.
Writing should be 100% compliant and reading should be 100% compliant when using the force_conformance option. We cant guarantee this but we have added a bunch of new conformance tests and any conformance issue reported will be treated as a bug.
A validate_json convivence function was added
This essentially just calls glz::read<glz::opts{.force_conformance = true}> on the input buffer with a glz::skip
My personal opinions on spec conformance: