7

Consider:

{
    "one": {
        "one1":"one11",
        "System Name":"ssss"
    },
    "two2": [
        ["two20", "two200"]
    ]
}

If I use '/* comments */' or //comments, I can not get JSON data.

But I have too much data, and I must add comments.

Is there another way to do it?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
huangxbd1990
  • 229
  • 2
  • 4
  • 10
  • Json strings are a data format used to simplify parsing, if you want to display nicely datas use a database or something – Charlie Nov 06 '14 at 08:48
  • As you can see from the link posted by Vicky, you cannot have comments in JSON files as it will be interpreted as data. There are some workarounds if you really, really need them, like defining a data element which is dummy, igonred and used only for commenting purposes – barca_d Nov 06 '14 at 08:48

1 Answers1

2

No, comments are not part of the JSON RFC 7159. However, there are JSON parsers which support C++-Style comments:

{
  "img":{ "width": 320, "height": 240 } // Picture details
}

See JSON++.

So the answer depends on what you are going to do with your JSON. The JavaScript-JSON parser (JSON.parse()) doesn't support this.

Community
  • 1
  • 1
lSoleyl
  • 309
  • 1
  • 7