Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid JSON-LD syntax; "@reverse" value must be an object. #1840

Closed
coret opened this issue Apr 22, 2022 · 2 comments
Closed

Invalid JSON-LD syntax; "@reverse" value must be an object. #1840

coret opened this issue Apr 22, 2022 · 2 comments

Comments

@coret
Copy link

coret commented Apr 22, 2022

#1795 added the @reverse property to the JSON-LD API. But, when an object doesn't have subjectValuesForReverse() the resulting JSON-LD will have @reverse: [] making the JSON-LD invalid.

I ran into this issue when processing the API's JSON-LD with https://json-ld.org/playground/ and https://www.easyrdf.org/converter. According to https://json-ld.org/spec/latest/json-ld/:

If the node object contains the @reverse key, its value MUST be a JSON object containing members representing reverse properties. Each value of such a reverse property MUST be an absolute IRI, a relative IRI, a compact IRI, a blank node identifier, a node object or an array containing a combination of these.

A possible fix would be to change

['@reverse' => $this->subjectValuesForReverse()]
into (count($reverse)>0?['@reverse' =>$reverse]:null)

where $reverse=$this->subjectValuesForReverse(); is added before

@zerocrates
Copy link
Member

Thanks for the report: we'll look into it, either removing the key or making it be an empty object rather than an empty array.

@zerocrates
Copy link
Member

The fix here is released, as part of version 3.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants