We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FromRDF() doesn't parse lists
FromRDF()
N-Quads:
<http://example.com/alice> <http://example.com#friends> _:1 . _:1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://example.com/bob> . _:1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
Go: Playground
package main import ( "encoding/json" "fmt" "github.com/linkeddata/gojsonld" ) func main() { nquads := `<http://example.com/alice> <http://example.com#friends> _:1 . _:1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://example.com/bob> . _:1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .` dataset, err := gojsonld.ParseDataset([]byte(nquads)) if err != nil { panic(err) } doc := gojsonld.FromRDF(dataset, &gojsonld.Options{}) d, _ := json.MarshalIndent(doc, "", " ") fmt.Printf("%v\n", string(d)) }
Result:
[ { "@id": "1", "http://www.w3.org/1999/02/22-rdf-syntax-ns#first": [ { "@id": "http://example.com/bob" } ], "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest": [ { "@list": [] } ] }, { "@id": "http://example.com/alice", "http://example.com#friends": [ { "@id": "1" } ] } ]
Node.js: RunKit
const jsonld = require("jsonld"); const result = await jsonld.fromRDF(`<http://example.com/alice> <http://example.com#friends> _:1 . _:1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://example.com/bob> . _:1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .`); JSON.stringify(result, null, 4)
[ { "@id": "http://example.com/alice", "http://example.com#friends": [ { "@list": [ { "@id": "http://example.com/bob" } ] } ] } ]
The text was updated successfully, but these errors were encountered:
Hi @iddan, thank you for opening this issue!
I'm afraid I won't have time to look into it short term, so it would be super awesome if you think you can provide a PR with the fix. :)
Sorry, something went wrong.
Hey @deiu! Thanks for the quick reply. I will try to get around this to unblock a PR in Cayley.
I found out https://github.com/piprate/json-gold got it right. Will consider whether it's better implementing it here or use their implementation.
No branches or pull requests
FromRDF()
doesn't parse listsExample
N-Quads:
Go: Playground
Result:
Node.js: RunKit
Result:
The text was updated successfully, but these errors were encountered: