Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

comments in json

JSON does not support comments.

/* CSS/PHP/JS/SQL
Multiple Lines
*
#Python
'''Python
Multiple Lines'''
Comment

how to comment in a json file

Sorry :3 no comments in JSON
Comment

how to comments in json file

{
	"_comment": "comment text goes here...",
    "name": "your-app-name",
    ...
}
Comment

json comments

JSON does not support comments.

HOWEVER, some popular .json files like (tsconfig, eslint, ...) allow comments
because the tools that use them deal with comments appropriatly.
Comment

why can i put comments in some json files

In some files the option for checking comments is off by default 
(tsconfig, tslint and eslint configs), as corresponding tools allow comments in
JSON (this is hardcoded). 

So IDEs recognize this and allow you to add comments even if standard 
doesnt allow.

Otherwise use:
{
	"_comment": "comment text goes here...",
    "name": "your-app-name",
    ...
}
Comment

Can comments be used in JSON?

No.

The JSON is data only, and if you include a comment, then it will be data too.

You could have a designated data element called "_comment" (or something) that should be ignored by apps that use the JSON data.

You would probably be better having the comment in the processes that generates/receives the JSON, as they are supposed to know what the JSON data will be in advance, or at least the structure of it.

But if you decided to:

{    "_comment": "comment text goes here...",    "glossary": {       "title": "example glossary",       "GlossDiv": {          "title": "S",          "GlossList": {             "GlossEntry": {                "ID": "SGML",                "SortAs": "SGML",                "GlossTerm": "Standard Generalized Markup Language",                "Acronym": "SGML",                "Abbrev": "ISO 8879:1986",                "GlossDef": {                   "para": "A meta-markup language, used to create markup languages such as DocBook.",                   "GlossSeeAlso": ["GML", "XML"]                },                "GlossSee": "markup"             }          }       }    } } 
Comment

Can comments be used in JSON?

No.
The JSON is data only, and if you include a comment, then it will be data too.
You could have a designated data element called "_comment" (or something) 
that should be ignored by apps that use the JSON data.
But if you decided to:
{
   "_comment": "comment text goes here...",
   "grocery": {
      "title": "Some title",
   }
}
Comment

Can comments be used in JSON ?

{
  "//": "Some browsers will use this to enable push notifications.",
  "//": "It is the same for all projects, this is not your project's sender ID",
  "gcm_sender_id": "1234567890"
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: find object in array javascript with property 
Javascript :: react native shadow above 
Javascript :: how to get seconds in timstamps js 
Javascript :: webpack react proxy not working 
Javascript :: toggle class javascript stack overflow 
Javascript :: Package path ./compat is not exported from 
Javascript :: sls invoke local 
Javascript :: moment check greater than current time 
Javascript :: what called window.onerror 
Javascript :: add javascript keyup on input 
Javascript :: javascript change background color 
Javascript :: getting days difference with moment js 
Javascript :: dinosaur game hacks 
Javascript :: angularjs download xml file 
Javascript :: javascript on keypu 
Javascript :: redirect to given link jquer 
Javascript :: javascript string methods 
Javascript :: two sum javascript 
Javascript :: convert date time to date function javascript 
Javascript :: stringify json swift 
Javascript :: Set timeouts to XMLHttpRequests in javascript 
Javascript :: math.factorial 
Javascript :: jquery toggleclass 
Javascript :: useeffect skip first render 
Javascript :: start a react native project with type script 
Javascript :: how to run bare react-native project 
Javascript :: vue dynamic route push with params 
Javascript :: rounding up a number so that it is divisible by 5 javascript 
Javascript :: upload file in react 
Javascript :: extract value from array of objects javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =