Author Topic: Adding Comment Support to JSON and Other File Types  (Read 424 times)

brebey

  • Community Member
  • Posts: 58
  • Hero Points: 2
Adding Comment Support to JSON and Other File Types
« on: January 08, 2020, 09:45:27 pm »
I want to add "//" as a line-comment indicator in JSON files (*.json), and in other kinds of files, as well.

How do I make SlickEdit recognize "//" as a line-comment indicator in a JSON file so that it will properly color-code the comment lines?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5174
  • Hero Points: 427
Re: Adding Comment Support to JSON and Other File Types
« Reply #1 on: January 09, 2020, 03:57:38 am »
Type the following on the SlickEdit command line:

Code: [Select]
help Color Coding::creating support for a new language

This help item has a lot of how to's including one for adding a line comment

brebey

  • Community Member
  • Posts: 58
  • Hero Points: 2
Re: Adding Comment Support to JSON and Other File Types
« Reply #2 on: January 09, 2020, 01:58:06 pm »
Perfect!  Up and going in 2 minutes.  Very impressive Help detail - kudos, SlickEdit!

Stu

  • Community Member
  • Posts: 59
  • Hero Points: 0
Re: Adding Comment Support to JSON and Other File Types
« Reply #3 on: January 23, 2020, 03:44:35 pm »
as an FYI, comments in JSON make it invalid. There are no comments in JSON by design.

brebey

  • Community Member
  • Posts: 58
  • Hero Points: 2
Re: Adding Comment Support to JSON and Other File Types
« Reply #4 on: January 23, 2020, 04:19:10 pm »
Yes, I understand that about JSON not having "real" comments;  thanks, though, for making the point.  I pre-process my JSON files before deserialization to remove the comments.  They are extremely useful for documenting configuration data, though, so it's worth the extra little step of stripping comments in-memory before deserialization.

Stu

  • Community Member
  • Posts: 59
  • Hero Points: 0
Re: Adding Comment Support to JSON and Other File Types
« Reply #5 on: January 24, 2020, 01:19:38 pm »
I actually do it as well :) As long as you know it makes it invalid and are aware, its all good. Its easy to think its just javacsript and add comments without knowing about it and then wonder why something is broken somewhere.