You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: A comment between an object key's colon and its value drops the value #240
If a comment sits after a key's colon and before its value, the comment is parsed as the value. The real value is then lost, or it spills into a bogus key and flattens a nested object. Comments elsewhere (before a key, between array items, after a value) are already skipped correctly. LLMs often annotate JSON this way, for example "age": // estimated\n 42.
Before parsing an object value, the parser now skips any #, // or /* */ comments and the whitespace after them. A lone / that doesn't start a comment is left alone. It adds test_parse_comment_between_colon_and_value to tests/test_parse_comment.py, which fails on master and passes with the fix. The full suite passes (420 passed, 2 skipped).
Happy to adjust it or open a PR if you enable that for me.
Activity
michaelkillgta commentedon Oct 26, 2026
I have a fix ready, but this repo only accepts PRs from collaborators, so I couldn't open one. The branch is here if it's useful: https://github.com/michaelkillgta/json_repair/tree/fix/comment-before-object-value (commit 0fc3b33).
Before parsing an object value, the parser now skips any
#,//or/* */comments and the whitespace after them. A lone/that doesn't start a comment is left alone. It addstest_parse_comment_between_colon_and_valuetotests/test_parse_comment.py, which fails on master and passes with the fix. The full suite passes (420 passed, 2 skipped).Happy to adjust it or open a PR if you enable that for me.