Skip to content

linearmouse/JSONPatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[WIP] JSONPatcher

Patch JSON / JSONC.

Background

When JSON / JSONC is parsed and re-encoded, some "trivial" information will be lost, such as whitespaces and comments.

Normally, this is not a problem for JSON, but for JSONC (or JSON5), it is a bad experience for users to find that comments are removed.

There are two approaches for preserving these "trivial" things when JSONC is modified programmatically:

  1. Build a parser that deserializes the "trivial" things into structures, and then serializes them back into JSONC.
  2. Generate the final JSONC content from the original JSONC content and the modified JSON content.

The first approach requires the developers to modify their structures by adding fields to store these "trivial" data. Therefore, this module implements the second approach.

Goals

The goal of this module is not to "efficiently" parse JSONC, but to make it easier for developers to switch from JSON to JSONC.

Current status

  • Scanner
  • Parser
  • Patcher
  • Formatter