Skip to content

RDF to Object Conversion drops type values if useNativeTypes is set to true #670

@niklasl

Description

@niklasl

In the JSON-LD 1.1 RDF to Object Conversion algorithm (8.5), step 2.4 says "If useNativeTypes is true", then steps into a nested set of steps. This is then followed by "Otherwise, if" steps 2.5-2.8.

This seems like a spec bug, since only if the value is actually converted within the nested checks of 2.4 should that step be considered complete. As it stands, step 2.5-2.8 will be ignored if useNativeTypes is set to true, resulting in {"@value": ...} objects with no @type at all.

If implemented verbatim (such as in TRLD), this will not properly convert the literals in this N-quads data:

<http://example.com> <http://example.com/property> "string" .
<http://example.com> <http://example.com/property> "hello"@en .
<http://example.com> <http://example.com/property> "No"^^<http://www.w3.org/2001/XMLSchema#boolean> .
<http://example.com> <http://example.com/property> "AAA"^^<http://www.w3.org/2001/XMLSchema#double> .
<http://example.com> <http://example.com/property> "{\"x\": 1}"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#JSON> .

I will prepare a PR with a spec fix and additional tests for this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions