Skip to content

The JSONPointer '/' #14245

@pkoppstein

Description

@pkoppstein

What happens?

On page 4 of https://datatracker.ietf.org/doc/html/rfc6901
there is an example of how the JSONPointer '/' should be evaluated.

The JSON example is:

{ "foo": ["bar", "baz"], : "": 0, ... }

And one of the JSONPointer examples is:

"/" 0

For this JSONPointer, however, DuckDB returns the entire document, e.g.

set variable json = json('{ "foo": ["bar", "baz"], "": 0}'::JSON);
select getvariable('json') -> '/' as value;
┌────────────────────────────┐
│           value            │
│            json            │
├────────────────────────────┤
│ {"foo":["bar","baz"],"":0} │
└────────────────────────────┘

Furthermore, it seems that DuckDB is effectively unable to use the
JSONPointer feature to access the value corresponding to a key equal
to the empty string, in any object in a JSON text.

In fact, I'm wondering whether there isn't a similar problem with
DuckDB's support for JSONPath. According to jsonpath.com,
the path to the value specified by a top-level "" key is: $.''

However according to DuckDB:

select getvariable('json') -> '$.''''' as value;
┌───────┐
│ value │
│ json  │
├───────┤
│       │
└───────┘

To Reproduce

set variable json = json('{ "foo": ["bar", "baz"], "": 0}'::JSON);
select getvariable('json') -> '/' as value;

OS:

MacOS

DuckDB Version:

1.1

DuckDB Client:

CLI

Hardware:

No response

Full Name:

Peter Koppstein

Affiliation:

Princeton University

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a source build

Did you include all relevant data sets for reproducing the issue?

Not applicable - the reproduction does not require a data set

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions