Skip to content

Empty result is decoded as an empty string even when output is set to json #689

Open
@grenik

Description

@grenik

If running a jq filter produces an empty result, the result is an empty string ('') even if the output option is set to json.

It may be a bit confusing because an empty string is also a different valid result (see examples below).

// this filter yields no results
jq.run('select(.foo == "bar")', {foo: ""}, {input: "json", output: "json"}).then(result => {
  // result is an empty string ''
});

// this filter yields an empty string
jq.run('.foo', {foo: ""}, {input: "json", output: "json"}).then(result => {
  // result is an empty string ''
});

I believe that undefined would be a better option because it is used neither in JSON nor in JQ.

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