SUMMARY kate seems to be missing a non-strict JSON highlighting. It seems to be pretty common nowadays for various applications to support and use JSON with more lenient rules, the most common one I've seen allowing both `"` and `'` for strings, allowing `//` line and `/*` block comments, and allowing trailing comments in array lists and object maps. Some applications like VS Code give this a different name like "JSON with Comments" and sometimes use a different file ending like .jsonc but often they don't. I believe even VS Code uses files with this lenient JSON sometimes named .json for various things. These files are currently a bit jarring to edit in kate because so much will be littered with bold red error markers. It would be nice if it were possible to turn that off. For example by providing "JSON (lenient)" and "JSON (strict)" variants in the "Markup" highlighting menu. Personally, I think maybe the non-strict mode should even be the default, but I know you tend to be vary with changes of defaults. But I think having it cover more actual real world use cases without making too narrow assumptions, even if it leads to less useful error displays for some users unless manually changed to strict mode, makes slightly more sense. STEPS TO REPRODUCE 1. Open a JSON file with comments 2. All the comments are marked red as errors 3. Try to find some way of fixing that OBSERVED RESULT There's only strict JSON highlighting, no lenient variant. EXPECTED RESULT There's a lenient JSON highlighting available, maybe even the default. SOFTWARE/OS VERSIONS Windows: macOS: Linux/KDE Plasma: openSUE Slowroll (available in About System) KDE Plasma Version: KDE Frameworks Version: 5.114.0 Qt Version: 5.15.10 ADDITIONAL INFORMATION
As far as I could see, at least as of version 24.02.0, the tool to "JSON Format Full File" is simply jq. I'm checking if there's a way to let jq be more lenient, but if it exists, you can just pass whatever options to jq that achieves that result. Or, you could change executable entirely, and use an external program you have installed which does the job. Go to Settings, search for "External tools", then select "JSON Format Full File" and click on the Edit button below.
I think it makes sense to both have a strict variant and a non-strict variant, since many users probably rely on both, as separate syntax options available at the same time. Given how many "JSON with comments" files are out there, my personal suggestion is that defaulting to the non-strict one would make more sense, but I understand many people disagree here. I hope this comment provides some insight on ideas for future plans.
At present, json is not totally strict: trailing comma are not displayed in error, nor is the absence of comma between array and object (which makes it possible to support jsonline). A non-strict variant already exists: javascript. It can be configured for json files in Settings -> Open/Save -> Modes & FileTypes. It does less checking of {}/[] matches, and there's no color distinction, but it should support all extensions. We'll see about a non-strict variant and whether it should be the default.
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/719
Git commit 99b75731857cc7c940e1c60c4a204740cdb9cdd9 by Christoph Cullmann, on behalf of Jonathan Poelen. Committed on 16/07/2025 at 06:23. Pushed by cullmann into branch 'master'. add JSONC (JSON with Comments) highlighting Although not recommended, the .json extension is used instead of .jsonc. As a result, JSONC has a higher priority than JSON. A +35 -0 autotests/folding/test.jsonc.fold A +42 -0 autotests/html/test.jsonc.dark.html A +42 -0 autotests/html/test.jsonc.html A +35 -0 autotests/input/test.jsonc A +35 -0 autotests/reference/test.jsonc.ref M +3 -0 data/CMakeLists.txt A +50 -0 data/generators/generate-jsonc.pl M +10 -1 data/syntax/json.xml https://invent.kde.org/frameworks/syntax-highlighting/-/commit/99b75731857cc7c940e1c60c4a204740cdb9cdd9
Git commit 529a39f6cf8bb59b53749c6e4987e6ce52d860ed by Christoph Cullmann, on behalf of Jonathan Poelen. Committed on 16/07/2025 at 06:23. Pushed by cullmann into branch 'master'. add JSON5 highlighting A +50 -0 autotests/folding/test.json5.fold A +57 -0 autotests/html/test.json5.dark.html A +57 -0 autotests/html/test.json5.html A +50 -0 autotests/input/test.json5 A +50 -0 autotests/reference/test.json5.ref A +177 -0 data/syntax/json5.xml https://invent.kde.org/frameworks/syntax-highlighting/-/commit/529a39f6cf8bb59b53749c6e4987e6ce52d860ed
I'm excited to see this addressed, thank you for your work! :-)