Crates.io | oxjsonld |
lib.rs | oxjsonld |
version | 0.2.0 |
created_at | 2025-05-15 20:12:03.085651+00 |
updated_at | 2025-09-13 15:59:41.684031+00 |
description | Parser and serializer for the JSON-LD 1.0 format |
homepage | |
repository | https://github.com/oxigraph/oxigraph/tree/master/lib/oxjsonld |
max_upload_size | |
id | 1675630 |
size | 263,571 |
OxJSON-LD is a parser and serializer for JSON-LD.
The entry points of this library are the two [JsonLdParser
] and [JsonLdSerializer
] structs.
The parser is a work in progress. Only JSON-LD 1.0 is supported at the moment, JSON-LD 1.1 is not supported yet.
The parser supports two modes:
with_profile(JsonLdProfile::Streaming)
method.Usage example counting the number of people in a JSON-LD file:
use oxrdf::{NamedNodeRef, vocab::rdf};
use oxjsonld::JsonLdParser;
let file = br#"{
"@context": {"schema": "http://schema.org/"},
"@graph": [
{
"@type": "schema:Person",
"@id": "http://example.com/foo",
"schema:name": "Foo"
},
{
"@type": "schema:Person",
"schema:name": "Bar"
}
]
}"#;
let schema_person = NamedNodeRef::new("http://schema.org/Person").unwrap();
let mut count = 0;
for triple in JsonLdParser::new().for_reader(file.as_ref()) {
let triple = triple.unwrap();
if triple.predicate == rdf::TYPE && triple.object == schema_person.into() {
count += 1;
}
}
assert_eq!(2, count);
This project is licensed under either of
<http://www.apache.org/licenses/LICENSE-2.0>
)<http://opensource.org/licenses/MIT>
)at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Oxigraph by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.