Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON column values get extraneously quoted #20

Closed
mhalle opened this issue Apr 12, 2019 · 1 comment
Closed

JSON column values get extraneously quoted #20

mhalle opened this issue Apr 12, 2019 · 1 comment
Milestone

Comments

@mhalle
Copy link

mhalle commented Apr 12, 2019

If the input to sqlite-utils insert includes a column that is a JSON array or object, sqlite-utils query will introduce an extra level of quoting on output:

# echo '[{"key": ["one", "two", "three"]}]' | sqlite-utils insert t.db t -

# sqlite-utils t.db 'select * from t'
[{"key": "[\"one\", \"two\", \"three\"]"}]

# sqlite3 t.db 'select * from t'
["one", "two", "three"]

This might require an imperfect solution, since sqlite3 doesn't have a JSON type. Perhaps fields that start with [" or {" and end with "] or "} could be detected, with a flag to turn off that behavior for weird text fields (or vice versa).

@simonw simonw added this to the 1.0 milestone May 25, 2019
@simonw
Copy link
Owner

simonw commented May 25, 2019

I'm going to implement this using a new --json-cols option which works by detecting any string value that starts with [ or { and is valid JSON.

@simonw simonw closed this as completed in 251e473 May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants