Moved from GitHub dgraph/4897
Posted by MichelDiz:
Experience Report
reference: Support JSON-LD in Dgraph
What you wanted to do
Have the possibility to insert JSON-LD directly into Dgraph instead of having to convert the entire dataset manually.
What you actually did
I tried to run a JSON-LD with JSON mutation.
{
"set": [
{
"@context": "http://schema.org/",
"@type": "Movie",
"name": "Avatar",
"Director": {
"@type": "Person",
"name": "James Cameron",
"birthDate": "1954-08-16"
},
"genre": "Science fiction",
"trailer": "../movies/avatar-theatrical-trailer.html"
}
]
}
Why that wasn’t great, with examples
The “@” character is a character reserved for language support. However, it is a character that is used between two words and not at the beginning of a word. Therefore, it makes no sense to reserve it that way.
Releasing this character would have a “kind of JSON-LD support”.
This would be a good step to allow different RDF based datasets to be loaded into Dgraph.
Any external references to support your case
Code reference
User comment about JSON-LD
Also check
Tests I made with other characters
Can not be mutate
_: b0 <@context> “test”.
_: b0 <\ context> “test”.
_: b0 <\ context> “test”.
_: b0 <~ context> “test”.
_: b0 <^ context> “test”.
_: b0 <`context>" test ".
_: b0 <{context> “test”.
_: b0 <} context> “test”.
Can
_: b0 <´context> “test”.
_: b0 <[context> “test”.
_: b0 <] context> “test”.
_: b0 <'context> “test”.
Other JSON-LD examples:
{
"@context": "http://schema.org/",
"@type": "Person",
"name": "Jane Doe",
"jobTitle": "Professor",
"telephone": "(425) 123-4567",
"url": "http://www.janedoe.com"
}
{
"@context": {
"ical": "http://www.w3.org/2002/12/cal/ical#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"ical:dtstart": {
"@type": "xsd:dateTime"
}
},
"ical:summary": "Lady Gaga Concert",
"ical:location": "New Orleans Arena, New Orleans, Louisiana, USA",
"ical:dtstart": "2011-04-09T20:00:00Z"
}
{
"@context": {
"name": "http://schema.org/name",
"description": "http://schema.org/description",
"image": {
"@id": "http://schema.org/image",
"@type": "@id"
},
"geo": "http://schema.org/geo",
"latitude": {
"@id": "http://schema.org/latitude",
"@type": "xsd:float"
},
"longitude": {
"@id": "http://schema.org/longitude",
"@type": "xsd:float"
},
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"name": "The Empire State Building",
"description": "The Empire State Building is a 102-story landmark in New York City.",
"image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg",
"geo": {
"latitude": "40.75",
"longitude": "73.98"
}
}
{
"@context": "https://www.w3.org/ns/activitystreams",
"@type": "Create",
"actor": {
"@type": "Person",
"@id": "acct:sally@example.org",
"name": "Sally"
},
"object": {
"@type": "Note",
"content": "This is a simple note"
},
"published": "2015-01-25T12:34:56Z"
}