Skip to content

JSON Merge

The JSON merge patcher performs a deep merge of two objects using defu. xtarterize uses it whenever it updates JSON configuration such as tsconfig.json, biome.json, or VS Code settings.

  • Existing keys take precedence; incoming values only fill gaps.
  • Nested objects merge recursively.
  • Arrays are replaced entirely, not concatenated. Tasks that need to combine arrays use a custom merge.

Object merging alone would discard comments and formatting, so file writes use a second patcher that edits the JSON text directly. It preserves:

  • Comments
  • Key order
  • Whitespace and indentation
  • Trailing commas in JSONC

JSON merge targets combine both steps: the object merge computes the target state, then the text patch applies it to the original file.

See the patchers overview for how the patchers fit together.