Skip to content

Incorrect JSON string representation when querying or exporting tables #7123

@trenta3

Description

@trenta3

What happens?

JSON values are exported or returned in queries in an incorrect simil-JSON format which makes it difficult to use when using clients, or impossible to export tables to json format.

Briefly the returned format encloses keys in single quotes (instead of double quotes) and completely removes quotes from string values made of alphanumeric characters.

I expect a JSON field to return properly formatted JSON when querying.

To Reproduce

INSTALL json;
LOAD json;
CREATE TABLE test (a JSON);
INSERT INTO test (a) VALUES ({'a': 'bc', 'd': 3.0 });
COPY test TO 'entries.json' (DELIMITER ',');

outputs Error: Invalid Input Error: Malformed JSON at byte 1 of input: unexpected character. Input: {'a': bc, 'd': 3.0}.

Analogously, when querying from the Python client, the returned data is difficult to parse, as the format is a non-standard one.

OS:

Linux x64 (Fedora 36)

DuckDB Version:

v0.7.2-dev1034 18142dc

DuckDB Client:

CLI

Full Name:

Dario Balboni

Affiliation:

Scuola Normale Superiore (University)

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions