digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.64k stars 195 forks source link

Different representation between @set and @list #514

Closed MarcusElevait closed 1 year ago

MarcusElevait commented 1 year ago

We have a simple turtle string:

ex:PersonShape sh:ignoredProperties ( rdf:type ) .

and the related context

'@id': 'http://www.w3.org/ns/shacl#ignoredProperties',
'@type': '@id',
'@container': '@set',

as the order of the ignored properties is not relevant, we want to use a set here. However, after compacting it, we get the following:

image

Whereas when we change the @container to @list we get the correct representation:

image

I thought that both, @set and @list should be a simple json array after compacting. Is this intentional?

davidlehn commented 1 year ago

Can you provide minimal sample input and context? Easiest way to debug this is to just put that in the playground and fiddle until it works.

MarcusElevait commented 1 year ago

Okay so here are the three quads, that are the input for this list:

{
    "termType": "Quad",
    "subject": {
      "termType": "BlankNode",
      "value": "_:n3-4"
    },
    "predicate": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#first"
    },
    "object": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
    },
    "graph": {
      "termType": "DefaultGraph",
      "value": ""
    }
  },
  {
    "termType": "Quad",
    "subject": {
      "termType": "BlankNode",
      "value": "_:n3-4"
    },
    "predicate": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"
    },
    "object": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
    },
    "graph": {
      "termType": "DefaultGraph",
      "value": ""
    }
  },
  {
    "termType": "Quad",
    "subject": {
      "termType": "NamedNode",
      "value": "http://example.com/ns#PersonShape"
    },
    "predicate": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/ns/shacl#ignoredProperties"
    },
    "object": {
      "termType": "BlankNode",
      "value": "_:n3-4"
    },
    "graph": {
      "termType": "DefaultGraph",
      "value": ""
    }
  }

and the context is this (as i wrote in my original post):

{
    '@id': 'http://www.w3.org/ns/shacl#ignoredProperties',
    '@type': '@id',
    '@container': '@set',
}
MarcusElevait commented 1 year ago

Sorry this was my bad, i was confused by the concept of sets and lists in shacl. so i will close this here.