umbrae / jsonlintdotcom

Source code for jsonlint.com
http://www.jsonlint.com/
ISC License
403 stars 279 forks source link

Seems that jsonlint can not detect comment properly #20

Closed linus-young closed 11 years ago

linus-young commented 11 years ago

I paste this to jsonlint:

[
  { "keys": ["ctrl+shift+r"], "command": "run_single_ruby_test",
    "context": [ { "key": "selector", "operator": "equal",
                   "operand": "source.ruby, source.rspec, text.gherkin.feature"
               } ]
  }, // single test

  { "keys": ["ctrl+shift+t"], "command": "run_all_ruby_test",
      "context": [ { "key": "selector", "operator": "equal",
             "operand": "source.ruby, source.rspec, text.gherkin.feature"
                } ]
  }, // test file

  { "keys": ["ctrl+shift+e"], "command": "run_last_ruby_test",
    "context": [ { "key": "selector", "operator": "equal",
           "operand": "source.ruby, source.rspec, text.gherkin.feature"
               } ], // test last test file
  },

  { "keys": ["ctrl+shift+x"], "command": "show_test_panel" }, // show test panel

  { "keys": ["alt+shift+v"], "command": "verify_ruby_file",
    "context": [ { "key": "selector", "operator": "equal",
                   "operand": "source.ruby"
               } ]
  }, // verify ruby syntax

  { "keys": ["ctrl+period"],
      "command": "switch_between_code_and_test",
      "args": {"split_view": false},
      "context": [ { "key": "selector", "operator": "equal",
                   "operand": "source.ruby, source.rspec, text.gherkin.feature"
               } ]
  }, // switch between code and test in single mode

  { "keys": ["ctrl+ctrl+period"],
      "command": "switch_between_code_and_test",
      "args": {"split_view": true},
      "context": [ { "key": "selector", "operator": "equal",
                   "operand": "source.ruby, source.rspec, text.gherkin.feature"
               } ]
  }, // switch between code and test in split view

  { "keys": ["ctrl+shift+c"], "command": "generate_file" } // create new file
]

Then I got this error:

Parse error on line 14:
...       ]    },    //singletest{      
---------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

It seems it refactored the code but cannot detect comments, Actually, the error is that there is an unnecessay comma in } ], // test last test file },

it should be } ] // test last test file},

May I miss something?

umbrae commented 11 years ago

Comments are not valid json. See the spec at json.org

On Tuesday, October 8, 2013, whyisyoung wrote:

I paste this to jsonlint:

[ { "keys": ["ctrl+shift+r"], "command": "run_single_ruby_test", "context": [ { "key": "selector", "operator": "equal", "operand": "source.ruby, source.rspec, text.gherkin.feature" } ] }, // single test

{ "keys": ["ctrl+shift+t"], "command": "run_all_ruby_test", "context": [ { "key": "selector", "operator": "equal", "operand": "source.ruby, source.rspec, text.gherkin.feature" } ] }, // test file

{ "keys": ["ctrl+shift+e"], "command": "run_last_ruby_test", "context": [ { "key": "selector", "operator": "equal", "operand": "source.ruby, source.rspec, text.gherkin.feature" } ], // test last test file },

{ "keys": ["ctrl+shift+x"], "command": "show_test_panel" }, // show test panel

{ "keys": ["alt+shift+v"], "command": "verify_ruby_file", "context": [ { "key": "selector", "operator": "equal", "operand": "source.ruby" } ] }, // verify ruby syntax

{ "keys": ["ctrl+period"], "command": "switch_between_code_and_test", "args": {"split_view": false}, "context": [ { "key": "selector", "operator": "equal", "operand": "source.ruby, source.rspec, text.gherkin.feature" } ] }, // switch between code and test in single mode

{ "keys": ["ctrl+ctrl+period"], "command": "switch_between_code_and_test", "args": {"split_view": true}, "context": [ { "key": "selector", "operator": "equal", "operand": "source.ruby, source.rspec, text.gherkin.feature" } ] }, // switch between code and test in split view

{ "keys": ["ctrl+shift+c"], "command": "generate_file" } // create new file]

Then I got this error:

Parse error on line 14: ... ] }, //singletest{ ---------------------^ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

It seems it refactored the code but cannot detect comments, Actually, the error is that there is an unnecessay comma in } ], // test last test file },

it should be } ] // test last test file},

May I miss something?

— Reply to this email directly or view it on GitHubhttps://github.com/umbrae/jsonlintdotcom/issues/20 .

linus-young commented 11 years ago

sorry, I'm new to json. Sorry to take your time.

umbrae commented 11 years ago

No problem!