Visitar URL original
Duplicate resource in JSON-LD frame output with embed=LAST · Issue #332 · jsonld-java/jsonld-java · GitHub
Skip to content

Duplicate resource in JSON-LD frame output with embed=LAST #332

Open

Description

@pvojtechovsky

The framing algorithm sometime keeps two occurrences of the resource with all attributes even if embed=LAST.
Json-LD input

{
	"@context" : {
		"@vocab" : "http://www.example.net/"
	},
	"@id": "#doc",
	"@type": "Document",
	"content": {
		"@list": [
			{
				"@id": "#question",
				"@type": "Question",
				"label" : "Why am I here twice?"
			},
			{
				"@id": "#block",
				"predicate": {
					"@id": "#question"
				}
			}
		]
	}
}

Frame:

{
	"@context" : {
		"@vocab" : "http://www.example.net/"
	},
	"@type" : "Document"
}

Cuttent buggy output:

{
  "@context" : {
    "@vocab" : "http://www.example.net/"
  },
  "@graph" : [ {
    "@id" : "#doc",
    "@type" : "Document",
    "content" : {
      "@list" : [ {
        "@id" : "#question",
        "@type" : "Question",                       //This attr should not be here, it is printed later
        "label" : "Why am I here twice?"       //This attr should not be here, it is printed later
      }, {
        "@id" : "#block",
        "predicate" : {
          "@id" : "#question",
          "@type" : "Question",
          "label" : "Why am I here twice?"
        }
      } ]
    }
  } ]
}

I will make PR with failing test case soon and link it here

Activity

  1. pvojtechovsky commented on Aug 2, 2022

    @pvojtechovsky
    Author

    By the way, there is a test case output
    /jsonld-java/src/test/resources/custom/frame-0009-out.jsonld
    which also contains duplicate resource. Is it bug or feature?

    I understood the embed=last as there is only one occurrence of the resource with all attributes and it is the last occurrence. All other occurrences are just reference over @id to that last occurrence. Am I wrong?

  2. pvojtechovsky commented on Aug 2, 2022

    @pvojtechovsky
    Author

    I just found that JSON-LD 1.1 implementation done by this project
    https://github.com/filip26/titanium-json-ld
    works well for this test case. So I am moving to that new project.

    So I do not need to have this issue solved in this project.

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