Support for JSON5
Motivation:
This PR enables JSON5 features available in Jackson, preserves JSON5 content as-is, and still provide the same support such as JSON Path that was available for JSON.
Limitation:
Comments in JSON5 content will be lost when a JSON Patch operation is applied. If you want to preserve the original content, you must use UPSERT_JSON.
Related: #538
Modifications:
- Java implementations)
Json5is introduced to deserialize JSON5 content.- Hexadecimal integers (0xdecaf) and trailing decimal points (8675309.) are unsupported due to the limitation of Jackson.
- Thanks to @ks-yim, most of the code comes from #655
Json5is used inEntryandJsonChangeto convert JSON5 file intoJsonNode.
- Updated
Util.JSON_FILE_PATH_PATTERNto allow the.json5extension. CentralDogmaRepository.importDir()now uploads raw JSON files without normalization.- Fixed
AbstractGitMirrorto mirror raw JSON content instead of the normalized one.
- Webapp implementations)
- Implemented JSON5 tokenizer for Monaco editor to provide syntax highlighting.
- It aligns Jackson's JSON5 features.
- Add
json5dependency to validate JSON5 content. - Fix
NewFile.tsxto extract a file extension and set it tolanguagefor Monaco editor.- Previously, it was hardcoded to
jsonso other languages such as YAML were not supported.
- Previously, it was hardcoded to
- Implemented JSON5 tokenizer for Monaco editor to provide syntax highlighting.
Result:
- Central Dogma now provides first-class support for JSON5.
- Closes #538
Co-authored-by: KS. Yim [email protected]
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 11.59% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title 'Support for JSON5' is concise, specific, and clearly summarizes the main feature being added across the entire changeset. |
| Description check | ✅ Passed | The description is comprehensive and directly related to the changeset, covering motivation, modifications, limitations, and results of the JSON5 support implementation. |
| Linked Issues check | ✅ Passed | The pull request fully addresses issue #538 by adding complete JSON5 support with file parsing, editor syntax highlighting, and content preservation as outlined in the objectives. |
| Out of Scope Changes check | ✅ Passed | All changes are within scope: Java-side JSON5 parsing infrastructure, webapp Monaco editor integration for JSON5, and supporting utility updates align with the #538 objectives. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
It seems trivial to also add support for yaml as well.
I'm on the same page.