# A tibble: 3 x 4
name power b id
<chr> <int> <int> <dbl>
1 scott NA NA NA
2 Amanda Dobbyn 4 2 2342423234.
3 Bob Rudis 5 NA 2342423234.
Last active
May 18, 2018 22:45
-
-
Save cboettig/e8a0947ced5224cd468af941dda002c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"stuff": { | |
"buried": { | |
"deep": [ | |
{ | |
"goodstuff": "here", | |
"name": "Bob Rudis", | |
"secret_power": 5 | |
}, | |
{ | |
"goodstuff": "here", | |
"name": "Amanda Dobbyn", | |
"secret_power": 4, | |
"more_nested_stuff": { | |
"a": 1, | |
"b": 2 | |
} | |
} | |
], | |
"alsodeep": 2342423234, | |
"deeper": { | |
"foo": [ | |
{ | |
"goodstuff": 5, | |
"name": "barb" | |
}, | |
{ | |
"goodstuff": "here", | |
"name": "scott" | |
} | |
] | |
} | |
} | |
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blob <- jsonlite::fromJSON("ex.json", simplifyVector=FALSE) | |
jqr::jq(x, 'recurse(.[]?) | objects | select(has("goodstuff"))') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
devtools::install_github("ropensci/rdflib") | |
library(rdflib) | |
## experimental functions for rdflib package | |
source(system.file("examples/as_rdf.R", package="rdflib")) | |
blob <- as_rdf(jsonlite::fromJSON(x, simplifyVector=FALSE), vocab = "x:") | |
q <- ' | |
PREFIX x: <x:> | |
SELECT ?name, ?power ?b ?id | |
WHERE { | |
?object x:goodstuff "here" . | |
?object x:name ?name . | |
OPTIONAL { ?object x:secret_power ?power } . | |
OPTIONAL { ?object x:more_nested_stuff ?y . | |
?y x:b ?b} . | |
OPTIONAL { | |
?parent x:deep ?object . | |
?parent x:alsodeep ?id | |
} | |
}' | |
rdf_query(blob, q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment