Skip to content

feat: upgrade to jsonc-parser 0.34 for JSON5 support - #16

Merged
dsherret merged 1 commit into
mainfrom
feat/json5
Sep 27, 2026
Merged

dsherret merged 1 commit into
mainfrom
feat/json5

Conversation

@dsherret

Copy link
Copy Markdown
Owner

Upgrades to jsonc-parser 0.34.0, which adds JSON5 support.

  • New ParseOptions: allowBareDecimalPointNumbers (.5, 5.), allowNonFiniteNumbers (Infinity, -Infinity, NaN) and allowExtendedStringEscapes (\x41, \v, \0, line continuations). They default to true for parse/parseToValue and to false for parseStrict/parseToValueStrict.
  • Unquoted property names can now be keywords (true, null) or contain $.
  • A lone \r now ends a line comment, so newlineKind() can return "\r". The TypeScript return type is updated to match.
  • Removes the README's sorting section.

Known limitations, both from jsonc-parser's serde_json conversion:

  • parseToValue throws on Infinity/NaN even when allowNonFiniteNumbers is on, because serde_json can't represent them. This is now noted in the option's doc comment.
  • toValue() on a CST node holding Infinity/NaN returns the string (e.g. "NaN"), not a number.

Exposes the new allowBareDecimalPointNumbers, allowNonFiniteNumbers and
allowExtendedStringEscapes options (off in parseStrict/parseToValueStrict),
and newlineKind() can now return "\r" since a lone carriage return ends a
line comment. Also removes the README's sorting section.
@dsherret
dsherret merged commit 7593b34 into main Sep 27, 2026
2 checks passed
@dsherret
dsherret deleted the feat/json5 branch September 27, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant