Skip to content

feat: upgrade jsonc-parser to 0.34 for json5 syntax - #71

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
Member

Upgrades jsonc-parser to 0.34, which parses JSON5 numbers, string escapes and property names. The plugin parses with the default options, so these are accepted without any config.

JSON5 input is formatted as follows:

  • numbers like .5, +5, 5., Infinity, NaN and 5.e3 are kept as written
  • property names like $key, true and null are quoted, like other unquoted names already were
  • escapes like \x41, \v and \0 are kept as written

String fixes

Rewriting strings (escaping raw control characters and converting single quotes to double) worked character by character, which changed the value of some strings:

  • a line continuation (a backslash then a newline) had its newline escaped, turning "a \⏎b" into "a \nb". It's now removed, since it means nothing and the printer can't print raw newlines
  • an escaped control character (ex. a backslash then a raw tab) became an escaped backslash followed by t. It's now escaped the JSON way (\t)
  • a single quoted string with an escaped double quote ('\"') came out as "\\"", which doesn't parse. This predates JSON5, but JSON5 makes single quoted strings more common

These are handled in one pass over the string's escape sequences.

.json5 files still aren't matched by the plugin.

jsonc-parser 0.34 accepts JSON5 numbers, string escapes and property
names. Fixes string handling that changed a string's value with them:

- a line continuation (backslash then newline) had its newline escaped,
  so it's now removed since it means nothing
- an escaped control character (ex. backslash then tab) became an escaped
  backslash, so it's now escaped the json way
- a single quoted string with an escaped double quote came out invalid
@dsherret
dsherret merged commit 2426cee into main Sep 27, 2026
2 checks passed
@dsherret
dsherret deleted the feat_json5 branch September 27, 2026 22:35
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