federomero / pretty-json

Atom plugin. Format JSON documents.
MIT License
94 stars 23 forks source link

fails to prettify django fixture with boolean value true or false #61

Closed Rage2010 closed 7 years ago

Rage2010 commented 7 years ago

Trying to prettify a json fixture generated by django (from python manage.py dumpdata) will fail if the data contains boolean value.

Example that will fail: [{ "model": "app1.model1", "pk": 1, "fields": { "name": "data1", "is_new": true, } }, { "model": "app1.model1", "pk": 2, "fields": { "name": "data2", "is_new": false, } }]

lexicalunit commented 7 years ago

The issue here is the trailing commas rather than the boolean literals. This is not valid JSON and so the parser fails to read it and can not prettify it. linter-jsonlint is a good way to avoid issues like this as it will automatically highlight syntax issues in JSON for you.

Rage2010 commented 7 years ago

Actually I made an error when stripping other data to make the sample. But the error seems to be the encoding of the generated file and not related to pretty-json.