Skip to content

Commit 1fddaff

Browse files
updated docs
1 parent d2759a1 commit 1fddaff

1 file changed

Lines changed: 71 additions & 4 deletions

File tree

  • docs/triply-db-getting-started/uploading-data

docs/triply-db-getting-started/uploading-data/index.md

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,19 @@ Only files that contain supported data formats will be added. See Section [Suppo
148148

149149
### Supported data formats
150150

151-
Files must contain RDF, CSV, TSV or XML data, and must use one of the supported file name extensions:
151+
Files must contain RDF, CSV, TSV, XML or JSON data, and must use one of the supported file name extensions:
152152

153153
| **Data Format** | **File name extension** |
154154
| --------------------------------------------------- | ----------------------- |
155155
| [Comma-Separated Values (CSV)](#csv-and-tsv-format) | `.csv` |
156156
| [Tab-Separated Values (CSV)](#csv-and-tsv-format) | `.tsv` |
157157
| [XML](#xml-format) | `.xml` |
158-
| JSON-LD | `.jsonld`, `.json` |
158+
| [GPX](#xml-format) | `.gpx` |
159+
| [JSON](#json-format) | `.json`, `.jsonl`, `.ndjson` |
160+
| JSON-LD | `.jsonld` |
159161
| N-Quads | `.nq` |
160162
| N-Triples | `.nt` |
161-
| RDF/XML | `.rdf`, `.owl`, `.owx` |
163+
| RDF/XML | `.rdf`, `.rdfs`, `.owl`, `.owx` |
162164
| TriG | `.trig` |
163165
| Turtle | `.ttl`, `.n3` |
164166

@@ -168,7 +170,7 @@ It is possible to upload up to 1,000 separate files in this way. When you have a
168170
| ------------------ | ----------------------- |
169171
| gzip | `.gz` |
170172
| bzip2 | `.bz2` |
171-
| tar | `tar` |
173+
| tar | `.tar`, `.tgz` |
172174
| XZ | `.xz` |
173175
| ZIP | `.zip` |
174176

@@ -220,6 +222,71 @@ select ?name ?category ?price where {
220222
When you upload XML files to TriplyDB, they are automatically converted to RDF using the Facade-X data model. This preserves the hierarchical structure of the XML document, making it queryable via SPARQL.
221223
See [here](https://sparql-anything.readthedocs.io/stable/formats/XML/) for more details on the Facade-X XML data model.
222224

225+
### JSON format
226+
227+
When you upload JSON files to TriplyDB, they are automatically converted to RDF using the Facade-X
228+
data model, the same model that is used for [XML](#xml-format) and [tabular](#csv-and-tsv-format)
229+
uploads. This preserves the structure of the JSON document, making it queryable via SPARQL. See
230+
[here](https://sparql-anything.readthedocs.io/stable/formats/JSON/) for more details on the Facade-X
231+
JSON data model.
232+
233+
Note that `.json` files are read as plain JSON. Use the `.jsonld` extension for
234+
[JSON-LD](https://www.w3.org/TR/json-ld11/) documents, so that their `@context` is interpreted.
235+
236+
Objects and arrays are both mapped to containers: the members of an object are linked by their key,
237+
the members of an array by their position.
238+
239+
- The document itself is typed `<http://sparql.xyz/facade-x/ns/root>`.
240+
- Object keys become properties in the `https://triplydb.com/json/def/` namespace. Spaces and
241+
non-ASCII characters in a key are percent-encoded, so the key `with space` becomes
242+
`https://triplydb.com/json/def/with%20space`.
243+
- Array members are linked by the container membership properties `rdf:_1`, `rdf:_2`, and so on, in
244+
the order in which they appear.
245+
- Strings become plain literals, booleans become `xsd:boolean` literals, and numbers become
246+
`xsd:decimal` literals. An exponent is expanded, because it is not part of the lexical space of
247+
`xsd:decimal`: `1e10` becomes `10000000000`. Digits are never rounded away, so a number that does
248+
not fit a 64-bit float — `1234567890123456789`, `0.000000000000000001` — keeps its full precision.
249+
- Uploads are information-preserving: a `null` is kept as the IRI
250+
`https://triplydb.com/json/def/null` rather than dropped, and a key that occurs twice in the same
251+
object yields both values.
252+
253+
Take for example this JSON file:
254+
255+
```json
256+
{
257+
"name": "Friends",
258+
"genres": ["Comedy", "Romance"],
259+
"cast": [
260+
{ "actor": "Jennifer Aniston", "role": "Rachel" },
261+
{ "actor": "Matt LeBlanc", "role": "Joey" }
262+
]
263+
}
264+
```
265+
266+
This can be queried as such:
267+
268+
```sparql
269+
prefix def: <https://triplydb.com/json/def/>
270+
prefix fx: <http://sparql.xyz/facade-x/ns/>
271+
272+
select ?name ?actor ?role where {
273+
?show a fx:root ;
274+
def:name ?name ;
275+
def:cast ?cast .
276+
?cast ?position ?member .
277+
?member def:actor ?actor ;
278+
def:role ?role .
279+
}
280+
```
281+
282+
The position of an array member is part of its predicate, so a variable in that position —
283+
`?position` above — iterates over every member, while `rdf:_1` selects only the first one.
284+
285+
A single file may hold several JSON documents, one after the other; each becomes its own root
286+
resource. This is what the `.jsonl` and `.ndjson` extensions of
287+
[JSON Lines](https://jsonlines.org) are for, but it works for a `.json` file with concatenated
288+
documents as well.
289+
223290
### Adding malformed data
224291

225292
TriplyDB only allows valid RDF data to be added. If data is malformed, TriplyDB will show an error message that indicates which part of the RDF data is malformed (see screenshot). If such malformed data is encountered, the RDF file must first be corrected and uploaded again.

0 commit comments

Comments
 (0)