Sublime Forum

Json syntax highlighting bug

#1
  "blah" : "blah",    // this comment is highlighted correctly
  "blah" : "blah"     // this comment has a red space before it

when a key value pair has a comment on it the comment is only displayed correctly if there is a comma present. if there is no comma then the space immediately before the // of the comment is displayed in red indicating a syntax error where there is none (other than comments like this are not actually supported in json : )

0 Likes

#2

I think this is always valid since the very first ST release because ST uses it as it’s settings file format… Or at least, it works at this moment in ST4.

0 Likes

#3

Thank you sir.

0 Likes

#4

the only “official” way of adding comments to json files is to create a comment structure item that physically takes up space in the structure you are defining. a comment is supposed to produce ZERO output but json comments per the standard DO produce output.
Pretty much everyone doing json parsers have added an unofficial // as a comment. the bug is related to this comment on non blank lines. if that line has a comma on the end the syntax highlighting is fine. if not there is a glitch.

p.s. what is ST4 ? I thougt ST3 was the latest

0 Likes

#5

ST4:
image

You can find ST4 on the official discord chat server: https://discord.gg/HcmwdVK
You can only test with a valid license since they are all dev builds at this moment.

0 Likes

#6

Issue confirmed in ST3211, but it no longer receives any update.

Probably had been fixed by https://github.com/sublimehq/Packages/pull/2194, which was not included in 3211.

0 Likes

#7

i can wait patiently for the release of ST4 where it seems to be fixed :slight_smile:
I only discovered this because i wrote my own json parser for my curses library (not related to ncurses) allowing for user interface layout via json :slight_smile:

0 Likes