Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

comments in json

JSON does not support comments.

/* CSS/PHP/JS/SQL
Multiple Lines
*
#Python
'''Python
Multiple Lines'''
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

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 :: javascript function return multiple 
Javascript :: radio group react 
Javascript :: sequelize max 
Javascript :: input events 
Javascript :: react bootstrap sweetalert2 
Javascript :: discord.js get user by username 
Javascript :: fontsize javascript 
Javascript :: label in lwc 
Javascript :: js int to string base 
Javascript :: javascript max 
Javascript :: js while continue 
Javascript :: get url in javascript 
Javascript :: change image on click javascript 
Javascript :: Square Every Digit 
Javascript :: javascript get type of var 
Javascript :: how to run a bash script with node js 
Javascript :: generate and download xml from javascript 
Javascript :: rerender a vue component 
Javascript :: date format date and time in js 
Javascript :: make property read-only javascript 
Javascript :: remove beginning of base64 javascript 
Javascript :: wait until a function finishes javascript 
Javascript :: eslint disable next line multiple rules 
Javascript :: dropzone remove error file 
Javascript :: xlsx to csv javascript 
Javascript :: react native showing double header stack and drawer menu 
Javascript :: javascript if statement 
Javascript :: post request with headers 
Javascript :: get json data into object 
Javascript :: java script remove last charecter from the string 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =