You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
❯ cat test.json | jq
{
"path": "/usr/bin/ruby",
"name": ""
}
parse error: Expected value before ',' at line 1, column 42
Failing with Python:
❯ python
Python 3.10.12 (main, Jun 6 2023, 22:43:10) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> f = open('test.json', 'r')
>>> data = json.load(f)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nix/store/bc45k1n0pkrdkr3xa6w84w1xhkl1kkyp-python3-3.10.12/lib/python3.10/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/nix/store/bc45k1n0pkrdkr3xa6w84w1xhkl1kkyp-python3-3.10.12/lib/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/nix/store/bc45k1n0pkrdkr3xa6w84w1xhkl1kkyp-python3-3.10.12/lib/python3.10/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 42 (char 41)
I think this can be remedied by wrapping the row results in brackets to make them a list which would make it compliant.
The text was updated successfully, but these errors were encountered:
There is reason and it was reason from almost 20 years ago, when the SQLite shell didn't have JSON output and jsonl wasn't a thing yet. The reason back then was anticipating wanting to join the output of multiple queries which is why use JSON and not a different format, since it would allow each query result to have different columns, and then have manual [ / ] put around it. Anyway that reason is very bogus now.
The fix is:
Make mode json output the [ / ] around the results each time
* json does an array including opening and closing square
brackets, comma separation
* jsonl is newline separated
Works by inspection, tests still need updating
See #483
The json output mode emits trailing commas which makes it difficult to parse with many standard JSON tools like
jq
or python itself.Here is me generating the list:
Failing with JQ:
Failing with Python:
I think this can be remedied by wrapping the row results in brackets to make them a list which would make it compliant.
The text was updated successfully, but these errors were encountered: