Output [] in JSON mode if no rows, closes #328

This commit is contained in:
Simon Willison 2021-09-22 13:20:04 -07:00
commit 7427a9137f
2 changed files with 15 additions and 1 deletions

View file

@ -2225,6 +2225,9 @@ def output_rows(iterator, headers, nl, arrays, json_cols):
)
yield line
first = False
if first:
# We didn't output any rows, so yield the empty list
yield "[]"
def maybe_json(value):