Different colorisation for Json properties and values
Solution 1:
The Scintilla component used by Notepad++ is in charge of the lexers for syntax highlighting. Apparently, the designer of that lexer didn't decide to differentiate between property names and values, though it seems like a good idea. To make a suggestion for that improvement in the lexer, you'd have to go see if the most recent Scintilla JSON Lexer has already incorporated that change, and if not, put in a request with the Scintilla project. If the change is already there, or if Scintilla releases a new version with that fix for you, you would then have to ask Notepad++ developer to upgrade Scintilla to include that fix. (And the last time NPP upgraded it's Scintilla was from 3.34 to 3.56 -- about 4 years ago -- compared to the most-recent Scintilla 4.1.3)
Workaround #1: change the Style Configurator > JSON > Operator color to have something that stands out between the property and value -- maybe with a bright yellow background or something -- to make it easier for your eye to find the :
separators, at least...
Workaround #2: In the Community Forums, Claudia Frank had done some work on a PythonScript-based lexer which would allow user defined languages with regular expressions, rather than the simplistic UDL 2.1. My collection of links to her effort is at https://notepad-plus-plus.org/community/topic/16164/bug-javascript-multiline-character-not-understood-by-notepad/11. With some effort, you might be able to define the regex necessary to parse JSON in a way you like.
update: You might be able to get a UDL (User Defined Language) to do what you want. I came up with a quick one that will get the highlighting differences you described. As a nasty side effect, it breaks folding (so cannot collapse { ... }
pairs. (I tried setting the UDL folding options, but nested folds weren't working right, at least on my first attempt)
- Language > Define Your Language...: Create New = JsonPropertyValues.
- Operators & Delimiters
-
Operators 1 =
, : " ' { }
, STYLER = set whatever colors you want for the punctuation -
Delimiter 1 style = OPEN:
:
, Close =((EOL))
, STYLER = set the color you want the VALUE side to be; setNesting:
to allowOperators 1
-
Delimiter 2 style = OPEN:
"
, Close ="
, STYLER = set the color for left-side (property) when in double-quotes, no nesting needed -
Delimiter 3 style = OPEN:
'
, Close ='
, STYLER = set the color for left-side (property) when in single-quotes, no nesting needed
You might want to set Nesting:
to include Numbers
on all of those STYLER entries above. And then go to the Comment & Number tab and define the STYLER to set the coloring for numbers as well.
You could set the Ext box to json
, if you want it to apply to all .JSON
files, or you could just manually apply Language > JsonPropertyValues to any JSON that you want to parse in this manner.
Anyway, this is a reasonable starting point, based on what you described; feel free to customize it or expand it beyond the features included.