Torann / json-ld

Extremely simple JSON-LD generator.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nesting (e.g. Review inside Book, ratings inside reviews etc.)

wturrell opened this issue · comments

Is passing one jsonld ContextType into another officially supported?
I assumed it would be, but none of the examples show it and I'm having loads of problems.

I've tried a couple of ways - e.g.

  • just nesting another call to \JsonLd\Context::create(Foo, $data) inside the main array
  • creating an entirely new instance with new \JsonLd\ContextTypes\Person()

Typically, the end output will either have an empty array where the nested context should be, or what looks like raw object data: i.e. only the @type defined and a "properties" array of everything, regardless of whether a value has been supplied - so mostly a long, empty list.

I've also come across situations where the second object works, but it fails on adding a third level (you may need to nest a Person (the reviewer) inside a Review inside a Book, for example).

Thanks in advance…