From 4cbd42052bca59d2fd722080116a31db64ce6798 Mon Sep 17 00:00:00 2001 From: Enrico Daga Date: Tue, 31 Jan 2023 17:27:44 +0000 Subject: [PATCH] Update documentation #201 See #333 --- docs/formats/JSON.md | 64 ++++++++++++++++++++++++++++++++++++++++++-- formats/JSON.md | 64 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 124 insertions(+), 4 deletions(-) diff --git a/docs/formats/JSON.md b/docs/formats/JSON.md index 023e26e1..3fbec95c 100644 --- a/docs/formats/JSON.md +++ b/docs/formats/JSON.md @@ -77,7 +77,7 @@ WHERE ] . ``` -### Example +### Example 1 Consider the following input, also located at [https://sparql-anything.cc/example1.json](https://sparql-anything.cc/example1.json) @@ -149,6 +149,65 @@ and get this result: | "Cougar Town" | | "Friends" | +### Example 2 + +Consider a JSON file with the following content: + +```json +{ + "Part01_001MIDDE": { + "builder": "Peter Gerritsz", + "originallocation": "Utrecht, Nicolaikerk", + "year": "1479" + }, + "Part01_002UTREJ": { + "builder": "Gerrit Petersz", + "originallocation": "", + "year": "1509" + } +} +``` + +the query: + +```sparql +PREFIX rdf: +PREFIX rdfs: +PREFIX fx: +PREFIX xyz: +PREFIX oont: +construct { + ?organ a oont:Organ ; + oont:builder ?builder_string ; + oont:consolelocation ?location_string ; + oont:dateOfBirth ?year_string ; +} WHERE { + SERVICE { + fx:properties fx:location "/app/history_base.json" . +bind(iri(concat(str(xyz:),?_organ)) as ?organ_slot) +?root a fx:root ; + ?organ_slot ?organ . +?organ xyz:builder ?builder_string ; + xyz:originallocation ?location_string ; + xyz:year ?year_string . +} +} +``` +generates the following RDF: +```turtle +@prefix fx: . +@prefix oont: . +@prefix rdf: . +@prefix rdfs: . +@prefix xyz: . + +[ rdf:type oont:Organ ; + oont:builder "Gerrit Petersz" ; + oont:consolelocation "" ; + oont:dateOfBirth "1509" +] . +``` + ## Options ### Summary @@ -161,7 +220,8 @@ and get this result: ### `json.path` !!! note - The `json.path` option will pre-process the JSON before the execution of the query. + The `json.path` option is only recommended if users need to filter a large JSON file, for example, in combination with the `slice` option. + It will pre-process the JSON before the execution of the query. In most cases, it is easier to query the JSON using a triple pattern, as in the [example described before](#Example). #### Description diff --git a/formats/JSON.md b/formats/JSON.md index 023e26e1..3fbec95c 100644 --- a/formats/JSON.md +++ b/formats/JSON.md @@ -77,7 +77,7 @@ WHERE ] . ``` -### Example +### Example 1 Consider the following input, also located at [https://sparql-anything.cc/example1.json](https://sparql-anything.cc/example1.json) @@ -149,6 +149,65 @@ and get this result: | "Cougar Town" | | "Friends" | +### Example 2 + +Consider a JSON file with the following content: + +```json +{ + "Part01_001MIDDE": { + "builder": "Peter Gerritsz", + "originallocation": "Utrecht, Nicolaikerk", + "year": "1479" + }, + "Part01_002UTREJ": { + "builder": "Gerrit Petersz", + "originallocation": "", + "year": "1509" + } +} +``` + +the query: + +```sparql +PREFIX rdf: +PREFIX rdfs: +PREFIX fx: +PREFIX xyz: +PREFIX oont: +construct { + ?organ a oont:Organ ; + oont:builder ?builder_string ; + oont:consolelocation ?location_string ; + oont:dateOfBirth ?year_string ; +} WHERE { + SERVICE { + fx:properties fx:location "/app/history_base.json" . +bind(iri(concat(str(xyz:),?_organ)) as ?organ_slot) +?root a fx:root ; + ?organ_slot ?organ . +?organ xyz:builder ?builder_string ; + xyz:originallocation ?location_string ; + xyz:year ?year_string . +} +} +``` +generates the following RDF: +```turtle +@prefix fx: . +@prefix oont: . +@prefix rdf: . +@prefix rdfs: . +@prefix xyz: . + +[ rdf:type oont:Organ ; + oont:builder "Gerrit Petersz" ; + oont:consolelocation "" ; + oont:dateOfBirth "1509" +] . +``` + ## Options ### Summary @@ -161,7 +220,8 @@ and get this result: ### `json.path` !!! note - The `json.path` option will pre-process the JSON before the execution of the query. + The `json.path` option is only recommended if users need to filter a large JSON file, for example, in combination with the `slice` option. + It will pre-process the JSON before the execution of the query. In most cases, it is easier to query the JSON using a triple pattern, as in the [example described before](#Example). #### Description