josdejong/jsonrepair

Cannot repair JSON with an extra closing brace before additional root properties

オープン

#159 opened on 2026/03/28

 (3 件のコメント) (0 件のリアクション) (0 人の担当者)TypeScript (88 件のフォーク)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (2,397 個のスター)
PR merge metrics
 (平均マージ 26d 22h) (30d で 2 merged PRs)

説明

jsonrepair appears unable to repair JSON where an extra closing brace closes the root object too early, followed by additional top-level properties.

Minimal repro:

import { jsonrepair } from 'jsonrepair'

const broken = '{"a":{"b":1}}},"c":2}'
console.log(jsonrepair(broken))

CLI repro:

printf '%s' '{"a":{"b":1}}},"c":2}' | jsonrepair

Actual result:

Error: Unexpected character "," at position 14

Expected result:

{"a":{"b":1},"c":2}

The library already documents repairs like adding missing closing brackets, repairing truncated JSON, stripping trailing commas, etc. This case seems like the inverse: there is one superfluous closing brace, and removing it would make the document valid again.

I ran into this with a larger LLM-generated JSON payload where a nested object had one extra } immediately before the next top-level key, which caused the root object to close early.

If this behavior is intentional and out of scope, a note in the README about not handling superfluous closing braces would also help.

コントリビューターガイド