feat: upgrade jsonc-parser to 0.34 for json5 syntax - #71
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
.5,+5,5.,Infinity,NaNand5.e3are kept as written$key,trueandnullare quoted, like other unquoted names already were\x41,\vand\0are kept as writtenString 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 \⏎b"into"a \nb". It's now removed, since it means nothing and the printer can't print raw newlinest. It's now escaped the JSON way (\t)'\"') came out as"\\"", which doesn't parse. This predates JSON5, but JSON5 makes single quoted strings more commonThese are handled in one pass over the string's escape sequences.
.json5files still aren't matched by the plugin.