0

I have a graph of schema:ProductGroup and schema:ProductModel nodes, and I've written a frame to output it in a nested structure, conceptually similar to the library-book-chapter examples. Everything works, except that the framed output includes a isVariantOf: null on the top-level ProductGroup, which I'd rather not have.

{
  "@context": {
    "@vocab": "http://schema.org/",
    "ex": "http://example.com/"
  },
  "@id": "ex:100",
  "@type": "ProductGroup",
  "hasVariant": [...],
  "isVariantOf": null,
  "name": "All The Things"
}

Full example in JSON-LD Playground (toggle between something like Flattened and Framed to get it to output correctly).

The top-level ProductGroup doesn't have an isVariantOf property. In my framing document, I'm matching on this being empty. But, I can't figure out how to omit the empty isVariantOf property in the output. I think I have to set the @omitDefault flag, but I'm having trouble figuring out where or how.

{
  "@context": {
    "@vocab": "http://schema.org/",
    "ex": "http://example.com/"
  },
  "@graph": {
    "@type": "ProductGroup",
    "@requireAll": true,
    "isVariantOf": []
  }
}
King Chung Huang
  • 5,026
  • 28
  • 24

1 Answers1

0

As noted in the Framing Spec, using the Match on the Absence of a Property mechanism explicitly adds a property with null to the output to indicate that the property does not exist. To remove it, you can re-compact the results using the frame as a context, as the Expansion Algorithm removes all properties with null values.

Gregg Kellogg
  • 1,831
  • 12
  • 8