userMod2
userMod2

Reputation: 8960

Json-ld not being converted to RDF as expected

I've converting some JSON-ld to RDF however it doesn't seem to produce RDF with the subject as I'd expect.

So, my JSON-ld looks like this:

{ 
  "@context":{ 
  "personid":"http://schema.org/id",
  "hasUpdateType":"http://schema.org/updateType"
},
"@type":"http://schema.org/Person",
"personid":"123456",
"hasUpdateType":{ 
  "@type":"updateType",
  "updateType":"Full"
}
}

And the RDF that is produced is

_:b0 <http://schema.org/id> "123456" .
_:b0 <http://schema.org/updateType> _:b1 .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .

However I was expecting something like (syntax not correct, just trying to show roughly):

person hasUpdatetype Full

Is my json-ld wrong?

To make the conversion from json-ld to rdf, I'm using the toRDF() from this library https://github.com/digitalbazaar/jsonld.js

Any help would be appreciated.

Thanks.

Upvotes: 1

Views: 297

Answers (1)

Gregg Kellogg
Gregg Kellogg

Reputation: 1906

You need to use @id (or an alias) to define the subject of the node object. You could potentially defined "persondid" as @id in the context.

You defined "hasUpdateTime" to expand to "schema:updateTime", so the expanded RDF should use "http://schema.org/updateType" as the predicate. If you want the value to be a single URI associated with "Full", use type coercion on "hasUpdateType". Something like the following may be closer to what you want.

{ 
  "@context":{ 
    "@base": "http://example.com/",
    "personid":"@id",
    "hasUpdateType": {"@id": "http://schema.org/updateType", "@type": "@id"}
  },
  "@type":"http://schema.org/Person",
  "personid":"123456",
  "hasUpdateType":"Full"
}

This would give you the following triples:

<http://example.com/123456> <http://schema.org/updateType> <http://example.com/Full> .
<http://example.com/123456> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .

Upvotes: 1

Related Questions