Skip to content

JSON-LD 1.1 missing scoped context support #288

@lagivan

Description

@lagivan

I'm testing the current implementation of JSON-LD 1.1 which is still in PR #284 and not merged to master. This implementation is missing support for the scoped contexts. I'm providing a minimal example here.

Simple input JSON-LD:

{
  "@graph": [
    {
      "@id": "http://www.example.com/id/ABC",
      "http://schema.org/name": "ABC",
      "http://www.example.com/def/P_ABC139": {
        "@id": "http://www.example.com/def/V_AAA953"
      }
    },
    {
      "@id": "http://www.example.com/def/V_AAA953"
    }
  ]
}

Simple JSON-LD context with scoped context:

{
  "@context": {
    "@version": 1.1,
    "id": "@id",
    "ex": "http://www.example.com/def/",
    "@vocab": "http://schema.org/",
    "usingScopedContext": {
      "@id": "http://www.example.com/def/P_ABC139",
      "@type": "@vocab",
      "@context": {
        "S": "http://www.example.com/def/V_AAA953",
        "P": "http://www.example.com/def/V_AAA952"
      }
    }
  }
}

Expected compacted output (taken from JSON-LD playground - https://json-ld.org/playground/):

{
  "@context": {
    "@version": 1.1,
    "id": "@id",
    "ex": "http://www.example.com/def/",
    "@vocab": "http://schema.org/",
    "usingScopedContext": {
      "@id": "http://www.example.com/def/P_ABC139",
      "@type": "@vocab",
      "@context": {
        "S": "http://www.example.com/def/V_AAA953",
        "P": "http://www.example.com/def/V_AAA952"
      }
    }
  },
  "id": "http://www.example.com/id/ABC",
  "name": "ABC",
  "usingScopedContext": "S"
}

Actual output of jsonld-java library:

{
  "id" : "http://www.example.com/id/ABC",
  "name" : "ABC",
  "usingScopedContext" : "ex:V_AAA953",
  "@context" : {
    "@version" : 1.1,
    "id" : "@id",
    "ex" : "http://www.example.com/def/",
    "@vocab" : "http://schema.org/",
    "usingScopedContext" : {
      "@id" : "http://www.example.com/def/P_ABC139",
      "@type" : "@vocab",
      "@context" : {
        "S" : "http://www.example.com/def/V_AAA953",
        "P" : "http://www.example.com/def/V_AAA952"
      }
    }
  }
}

So the problematic part is that "usingScopedContext" : "ex:V_AAA953", is not expanded properly into "usingScopedContext": "S".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions