Bug 383286

Summary: Highlight JSON errors
Product: [Frameworks and Libraries] frameworks-syntax-highlighting Reporter: Jaime Torres <jtamate>
Component: syntaxAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

Description Jaime Torres 2017-08-08 16:20:05 UTC
In JSON, the arrays and dictionaries can't have a trailing ",".
But they are very hard to catch by the human eye without colouring help (I know, I've lost more than one hour because of them).

It would be very nice if those errors (and probably others) are highlighted with inverted foreground and background.
Comment 1 Dominik Haumann 2017-09-18 17:03:51 UTC
Can you provide a piece of sample code you are talking about?

It may very well be that your request is out of scope, since we cannot look into the "future", i.e. following lines, to mark a ',' as error.

For real syntax checks, you typically use a linter.
Comment 2 Jaime Torres 2017-09-18 18:20:21 UTC
Something like this:
{"node1":["child1","child2",],["other1","other2"],}
where the last comma of the first array and the last comma of the dictionary, in the middle of a one page json are almost invisible.

If this is not possible, is there a json lint that can be integrated with kate, I mean that kate is able to call it with the current file and understand the lint output?
Comment 3 Dominik Haumann 2017-09-18 19:13:33 UTC
If it is in the same line like in your example: {"node1":["child1","child2",],["other1","other2"],}

Then it will work.

However, as soon as you have
{"node1":[
     "child1",
     "child2",
  ],
  [
     "other1",
     "other2"],
}

Then it will not work anymore. Which is also kind of inconsistent... Not yet convinced we should add this.
Comment 4 Jaime Torres 2017-09-18 19:18:58 UTC
If you are not convinced, then let's postpone this wish until there is a cheap way to not just highlight the right syntax elements but also the wrong ones.