in Technology by
Can We use comments inside a JSON file? If so, how?

1 Answer

0 votes
by

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"
            }
         }
      }
   }
}

Related questions

0 votes
    Can we use JSON instead of YAML while developing docker-compose file in Docker?...
asked Jun 21, 2021 in Technology by JackTerrance
0 votes
    I have a JSON File with database environment configuration called env-config.json like this: { "LATEST":{ ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I am using a framework, which returns invalid JSON String like: /* { "myobject" : "test"} */ ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    How can we write JSON data to a file?...
asked Jan 11, 2021 in Technology by JackTerrance
0 votes
    Can we nest comments in a C code?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    Which of the following is correct? A.We can use json data directly in axios B.we can use json data directly ... only we can use axios Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    Can we check locks in database? If so, how can we do this lock check?...
asked Nov 9, 2020 in Technology by Editorial Staff
0 votes
    I have an Item entity which have an "access" field, typed as json, that is added through a migration. I'm ... syntax. Currently I'm trying to do something like $this->addSql(...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    How can we POST JSON data with cURL?...
asked Jan 11, 2021 in Technology by JackTerrance
0 votes
    How can we pretty-print JSON in a shell script?...
asked Jan 11, 2021 in Technology by JackTerrance
0 votes
    I'm completely new in logging but familiar in SQL queries. I'm now experimenting with Serilog and Seq. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    {{#if docs}} {{#each docs}} customer number : {{this.customer}} number of liters required : {{ ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    If you have a lot of objects that you want to save to a file, we use ________ function. (a) save() ... and Operations of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    If we want to save individual R objects to a file, we use the _______ function. (a) save() (b) save ... and Operations of R Programming Select the correct answer from above options...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    2. Read this dialogue. Which argument do you agree with? Why? Amit: Looking at the constitutional provisions, it ... to be the Prime Minister. Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
...