prantlf / jsonlint

JSON/CJSON/JSON5 parser, syntax & schema validator and pretty-printer with a command-line client, written in pure JavaScript.
http://prantlf.github.io/jsonlint/
MIT License
38 stars 9 forks source link

Error output display incorrect for files with windows-style line breaks #1

Closed misterflippy closed 5 years ago

misterflippy commented 5 years ago

The error location output is incorrect for files with windows-style line breaks. (\r\n)

Example file: test.zip

This file produces error output of:

Parse error on line 4, column 3:
} } "bar":
---------------------^
Unexpected token }

Expected output: The output should include the referenced bracket ("}") and the arrow should point to it like this:

Parse error on line 4, column 3:
...": {    "bar":  }}
-------------------^
Unexpected token }
prantlf commented 5 years ago

Thanks a lot for reporting this and for the right fix! I merged and released it in v8.0.1. I included your example as a new test case.

misterflippy commented 5 years ago

Glad to help! Thanks for the library :)