Skip to content

Commit

Permalink
Update documentation #201 See #333
Browse files Browse the repository at this point in the history
  • Loading branch information
enridaga committed Jan 31, 2023
1 parent 52d0ed4 commit 98ec251
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 2 deletions.
78 changes: 77 additions & 1 deletion docs/formats/JSON.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT ?seriesName
WHERE {
SERVICE <x-sparql-anything:https://sparql-anything.cc/example1.json> {
?tvSeries xyz:name ?seriesName .
?tvSeries xyz:stars ?star .
?star fx:anySlot "Courteney Cox" .
}
}
```

and get this result:

| seriesName |
|---------------|
| "Cougar Town" |
| "Friends" |

## Options

### Summary
Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand Down
78 changes: 77 additions & 1 deletion formats/JSON.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT ?seriesName
WHERE {
SERVICE <x-sparql-anything:https://sparql-anything.cc/example1.json> {
?tvSeries xyz:name ?seriesName .
?tvSeries xyz:stars ?star .
?star fx:anySlot "Courteney Cox" .
}
}
```

and get this result:

| seriesName |
|---------------|
| "Cougar Town" |
| "Friends" |

## Options

### Summary
Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 98ec251

Please sign in to comment.