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 :: how to insert a value into an array javascript 
Javascript :: salvar no localStorage react 
Javascript :: nodejs: basic: send html page to Browser 
Javascript :: route not getting refresh with different id in angular 
Javascript :: javascript object type 
Javascript :: material ui icons next js 
Javascript :: javascript execute after 1 second 
Javascript :: getmonth js 
Javascript :: react window.addEventListener 
Javascript :: adding debounce in autocomplete material ui 
Javascript :: check if browser supports Local Storage 
Javascript :: Search array of objects for existing value 
Javascript :: form validation for email in js 
Javascript :: js map array to object 
Javascript :: use css child selector inside js 
Javascript :: kafka nodejs example 
Javascript :: javascript arreglos 
Javascript :: react datepicker 
Javascript :: JavaScript then() method 
Javascript :: redux toolkit remove from array 
Javascript :: generator function javascript 
Javascript :: .includes is not a function 
Javascript :: jquery add attribute without value 
Javascript :: axios error handling 
Javascript :: position of the mouse cursor javascript 
Javascript :: javascript substring 
Javascript :: maximum number in javascript 
Javascript :: how set type of string value to number in js 
Javascript :: how to access data in json format using asp.net c# 
Javascript :: jquery modal show 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =