From 98ec25130e8b2a63ba4d3a778b9f005f63b4979e Mon Sep 17 00:00:00 2001 From: Enrico Daga Date: Tue, 31 Jan 2023 17:24:09 +0000 Subject: [PATCH] Update documentation #201 See #333 --- docs/formats/JSON.md | 78 +++++++++++++++++++++++++++++++++++++++++++- formats/JSON.md | 78 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 154 insertions(+), 2 deletions(-) diff --git a/docs/formats/JSON.md b/docs/formats/JSON.md index 1ee8f365..023e26e1 100644 --- a/docs/formats/JSON.md +++ b/docs/formats/JSON.md @@ -77,6 +77,78 @@ WHERE ] . ``` +### Example + +Consider the following input, also located at [https://sparql-anything.cc/example1.json](https://sparql-anything.cc/example1.json) + +```json +[ + { + "name":"Friends", + "genres":[ + "Comedy", + "Romance" + ], + "language":"English", + "status":"Ended", + "premiered":"1994-09-22", + "summary":"Follows the personal and professional lives of six twenty to thirty-something-year-old friends living in Manhattan.", + "stars":[ + "Jennifer Aniston", + "Courteney Cox", + "Lisa Kudrow", + "Matt LeBlanc", + "Matthew Perry", + "David Schwimmer" + ] + }, + { + "name":"Cougar Town", + "genres":[ + "Comedy", + "Romance" + ], + "language":"English", + "status":"Ended", + "premiered":"2009-09-23", + "summary":"Jules is a recently divorced mother who has to face the unkind realities of dating in a world obsessed with beauty and youth. As she becomes older, she starts discovering herself.", + "stars":[ + "Courteney Cox", + "David Arquette", + "Bill Lawrence", + "Linda Videtti Figueiredo", + "Blake McCormick" + ] + } +] +``` + +With SPARQL Anything you can select the TV series starring "Courteney Cox" with the SPARQL query: + +```sparql +PREFIX xyz: +PREFIX rdf: +PREFIX fx: + +SELECT ?seriesName +WHERE { + + SERVICE { + ?tvSeries xyz:name ?seriesName . + ?tvSeries xyz:stars ?star . + ?star fx:anySlot "Courteney Cox" . + } + +} +``` + +and get this result: + +| seriesName | +|---------------| +| "Cougar Town" | +| "Friends" | + ## Options ### Summary @@ -88,6 +160,10 @@ WHERE ### `json.path` +!!! note + The `json.path` option 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 One or more JsonPath expressions as filters. E.g. `json.path=value` or `json.path.1`, `json.path.2`, `...` to add multiple expressions. @@ -148,7 +224,7 @@ Located at [https://sparql-anything.cc/example1.json](https://sparql-anything.cc ] ``` -##### Use Case 1: Constructing a Facade-X RDF Graph only only containers that match the Json Path ``$[?(@.name=="Friends")]``. +##### Use Case 1: Constructing a Facade-X RDF Graph selecting only containers that match the Json Path ``$[?(@.name=="Friends")]``. ###### Query diff --git a/formats/JSON.md b/formats/JSON.md index 1ee8f365..023e26e1 100644 --- a/formats/JSON.md +++ b/formats/JSON.md @@ -77,6 +77,78 @@ WHERE ] . ``` +### Example + +Consider the following input, also located at [https://sparql-anything.cc/example1.json](https://sparql-anything.cc/example1.json) + +```json +[ + { + "name":"Friends", + "genres":[ + "Comedy", + "Romance" + ], + "language":"English", + "status":"Ended", + "premiered":"1994-09-22", + "summary":"Follows the personal and professional lives of six twenty to thirty-something-year-old friends living in Manhattan.", + "stars":[ + "Jennifer Aniston", + "Courteney Cox", + "Lisa Kudrow", + "Matt LeBlanc", + "Matthew Perry", + "David Schwimmer" + ] + }, + { + "name":"Cougar Town", + "genres":[ + "Comedy", + "Romance" + ], + "language":"English", + "status":"Ended", + "premiered":"2009-09-23", + "summary":"Jules is a recently divorced mother who has to face the unkind realities of dating in a world obsessed with beauty and youth. As she becomes older, she starts discovering herself.", + "stars":[ + "Courteney Cox", + "David Arquette", + "Bill Lawrence", + "Linda Videtti Figueiredo", + "Blake McCormick" + ] + } +] +``` + +With SPARQL Anything you can select the TV series starring "Courteney Cox" with the SPARQL query: + +```sparql +PREFIX xyz: +PREFIX rdf: +PREFIX fx: + +SELECT ?seriesName +WHERE { + + SERVICE { + ?tvSeries xyz:name ?seriesName . + ?tvSeries xyz:stars ?star . + ?star fx:anySlot "Courteney Cox" . + } + +} +``` + +and get this result: + +| seriesName | +|---------------| +| "Cougar Town" | +| "Friends" | + ## Options ### Summary @@ -88,6 +160,10 @@ WHERE ### `json.path` +!!! note + The `json.path` option 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 One or more JsonPath expressions as filters. E.g. `json.path=value` or `json.path.1`, `json.path.2`, `...` to add multiple expressions. @@ -148,7 +224,7 @@ Located at [https://sparql-anything.cc/example1.json](https://sparql-anything.cc ] ``` -##### Use Case 1: Constructing a Facade-X RDF Graph only only containers that match the Json Path ``$[?(@.name=="Friends")]``. +##### Use Case 1: Constructing a Facade-X RDF Graph selecting only containers that match the Json Path ``$[?(@.name=="Friends")]``. ###### Query