dmeranda / demjson

Python module for JSON data encoding, including jsonlint. See the project Wiki here on Github. Also read the README at the bottom of this page, or the project homepage at
http://deron.meranda.us/python/demjson/
Other
302 stars 76 forks source link

Error types need to converted into booleans #11

Closed jannepeltola closed 9 years ago

jannepeltola commented 9 years ago

I noticed that jsonlint return values don’t work properly. Code outside this method treats these values as booleans.

Steps to reproduce:

tmp $ cat test.json
{
    "foo" : [ 1,2,3]
}
tmp $ jsonlint test.json
test.json: ok
tmp $ echo $?
0
tmp $ cat test.json
{
    "foo" : [ 1,2,3
}
tmp $ jsonlint test.json
test.json:3:0: Error: Expected a ']' but saw '}'
   |  At line 3, column 0, offset 22
   |  Array started at line 2, column 12, offset 14
test.json: has errors
tmp $ echo $?
0

$? should be 1, and after applying the attached patch it is.

dmeranda commented 9 years ago

I have opened Issue https://github.com/dmeranda/demjson/issues/12 to track this bug; you may subscribe to it if you want. This bug has been reported by multiple people and will be fixed shortly. Thanks for your suggested patch.