centraldogma icon indicating copy to clipboard operation
centraldogma copied to clipboard

Support for JSON5

Open ikhoon opened this issue 4 weeks ago • 2 comments

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)
    • Json5 is 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
      • Json5 is used in Entry and JsonChange to convert JSON5 file into JsonNode.
    • Updated Util.JSON_FILE_PATH_PATTERN to allow the .json5 extension.
    • CentralDogmaRepository.importDir() now uploads raw JSON files without normalization.
    • Fixed AbstractGitMirror to 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 json5 dependency to validate JSON5 content.
    • Fix NewFile.tsx to extract a file extension and set it to language for Monaco editor.
      • Previously, it was hardcoded to json so other languages such as YAML were not supported.

Result:

  • Central Dogma now provides first-class support for JSON5.
  • Closes #538

Co-authored-by: KS. Yim [email protected]

ikhoon avatar Dec 04 '25 14:12 ikhoon

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Dec 04 '25 14:12 coderabbitai[bot]

It seems trivial to also add support for yaml as well.

I'm on the same page.

ikhoon avatar Dec 11 '25 02:12 ikhoon