You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/jsonld_serialization.py
+20-9Lines changed: 20 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,35 @@
1
1
"""
2
-
JSON-LD is "A JSON-based Serialization for Linked Data" (https://www.w3.org/TR/json-ld/) that RDFLib implements for RDF serialization.
2
+
JSON-LD is "A JSON-based Serialization for Linked Data" (https://www.w3.org/TR/json-ld/)
3
+
that RDFLib implements for RDF serialization.
3
4
4
-
This file demonstrated some of the JSON-LD things you can do with RDFLib. Parsing & serializing so far. More to be added later.
5
+
This file demonstrated some of the JSON-LD things you can do with RDFLib. Parsing &
6
+
serializing so far. More to be added later.
5
7
6
8
7
9
Parsing
8
10
-------
9
-
There are a number of "flavours" of JSON-LD - compact and verbose etc. RDFLib can parse all of these in a normal RDFLib way.
11
+
12
+
There are a number of "flavours" of JSON-LD - compact and verbose etc. RDFLib can parse
13
+
all of these in a normal RDFLib way.
10
14
11
15
12
16
Serialization
13
17
-------------
14
-
JSON-LD has a number of options for serialization - more than other RDF formats. For example, IRIs within JSON-LD can be compacted down to CURIES when a "context" statment is added to the JSON-LD data that maps identifiers - short codes - to IRIs and namespace IRIs like this:
15
18
16
-
# here the short code "dcterms" is mapped to the IRI http://purl.org/dc/terms/ and "schema" to https://schema.org/, as per RDFLib's in-build namespace prefixes
19
+
JSON-LD has a number of options for serialization - more than other RDF formats. For
20
+
example, IRIs within JSON-LD can be compacted down to CURIES when a "context" statement
21
+
is added to the JSON-LD data that maps identifiers - short codes - to IRIs and namespace
22
+
IRIs like this:
17
23
18
-
"@context": {
19
-
"dct": "http://purl.org/dc/terms/",
20
-
"schema": "https://schema.org/"
21
-
}
24
+
.. code-block:: json
25
+
26
+
"@context": {
27
+
"dcterms": "http://purl.org/dc/terms/",
28
+
"schema": "https://schema.org/"
29
+
}
30
+
31
+
Here the short code "dcterms" is mapped to the IRI http://purl.org/dc/terms/ and
32
+
"schema" to https://schema.org/, as per RDFLib's in-build namespace prefixes.
0 commit comments