Load a json-ld string into a Grax schema #25
-
I am sorry to be so annoying, but I am learning the Semantic Web in the spare time and it is incredibly hard to find informations related to Elixir for such a niche topic. Feel free to ignore this message or answer with a RTFM, really! I have a very precise goal in mind: load data from a json-ld string into a Grax Schema. Here is the code I am using, with comments:
It's not clear to me what are the steps I have to perform to achieve my goal. Thanks for the patience, in case you reached this point :) Cheers |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
No worries at all about asking questions! Learning Semantic Web technologies can indeed be challenging, especially when working with less common tech stacks like Elixir. # Your JSON-LD should include an @id like this:
input_str = """
{
"@context": "http://schema.org/",
"@type": "Organization",
"@id": "https://www.acme.com#org",
"name": "acme inc.",
"description": "an evil company",
"url": "https://www.acme.com",
"logo": "https://www.acme.com/logo.png"
}
"""
# Then you can load it like this:
input_str
|> JSON.LD.read_string!()
|> Cjp.Schema.Organization.load(~I<https://www.acme.com#org>) |
Beta Was this translation helpful? Give feedback.
-
Oh, I thought The BTW: if you're input indeed consists of multiple graphs and you want to load from all of them, you can aggregate the dataset with
|
Beta Was this translation helpful? Give feedback.
Oh, I thought
load/2
would accept datasets. Maybe I'll change that.The
then
, however, shouldn't be necessary.BTW: if you're input indeed consists of multiple graphs and you want to load from all of them, you can aggregate the dataset with
RDF.Graph.new/1
: