Visitar URL original
omit doesn't work for multiple objects · Issue #316 · jsonld-java/jsonld-java · GitHub
Skip to content

omit doesn't work for multiple objects #316

Open

Description

@garpinc

I'm getting back following even though I've specified to omit graph

{
  "@context" : [ "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary/ClassConcept", "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary/PrimaryKey", "http://cambridgesemantics.com/ontologies/2018/06/MetadataDictionary/MetadataDictionary" ],
  "@graph" : [ {
    "uri" : "http://test1",
    "type" : "metaframe:MetadataDictionary",
    "metaDataConcepts" : {
      "uri" : "http://testc1",
      "type" : "metaframe:ClassConcept",
      "primaryKey" : [ {
        "uri" : "http://pk1",
        "type" : "metaframe:PrimaryKey",
        "priority" : "5"
      }, {
        "uri" : "http://pk2",
        "type" : "metaframe:PrimaryKey",
        "priority" : "6"
      } ]
    },
    "title" : "test1"
  }, {
    "uri" : "http://test2",
    "type" : "metaframe:MetadataDictionary",
    "title" : "test2"
  } ]
}

I see

2.3.4 Omit graph flag
The omit graph flag determines if framed output containing a single node object is contained within @graph, or not. The initial value for the omit graph flag is set using the omitGraph option, or based on the processing mode; if processing mode is json-ld-1.0, the output always includes a @graph member, otherwise, the @graph member is used only to describe multiple node objects, consistent with compaction. See § 4.2.2 Framing Algorithm for a further discussion.

which seems to indicate "@graph member is used only to describe multiple node".. But what do I do if I want no graph at all and I just want a list of the objects?

Activity

  1. acka47 commented on Jun 8, 2021

    @acka47

    I see several reasons the data couldn't be processed as you wish:

    1. It is not valid JSON-LD: The @context links do not point to valid JSON-LD context files (see also the JSON-LD playground)
    2. You use uri instead of the JSON-LD keyword @id to indicate the URI of a node.
    3. However, if I use a valid context (like https://schema.org for testing purpose) and @id you won't get rid of the @graph anyway because you have two distinct nodes (http://test1 and http://test2) which are not linked to each other so that one description can not be embedded in the other and @graph becomes necessary.

    Here is some correct JSON-LD for testing:

    {
      "@context":"https://schema.org",
      "@graph":[
        {
          "@id":"http://test1",
          "type":"metaframe:MetadataDictionary",
          "metaDataConcepts":{
            "@id":"http://testc1",
            "type":"metaframe:ClassConcept",
            "primaryKey":[
              {
                "@id":"http://pk1",
                "type":"metaframe:PrimaryKey",
                "priority":"5"
              },
              {
                "@id":"http://pk2",
                "type":"metaframe:PrimaryKey",
                "priority":"6"
              }
            ]
          },
          "title":"test1"
        },
        {
          "@id":"http://test2",
          "type":"metaframe:MetadataDictionary",
          "title":"test2"
        }
      ]
    }

    When I put this in the playground and add a JSON-LD frame with the node of type metaframe:MetadataDictionary as root object and @embed": "@always", there will still be two separate nodes that need a @graph around them to be represented as JSON-LD. See https://tinyurl.com/246b6sfp.

  2. dr0i commented on Jun 15, 2021

    @dr0i
    Member

    @acka47 thx for clarification/explanation! Very detailed :)
    @garpinc is this helpful to solve your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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