extern crate async_std;
extern crate iref;
extern crate json_ld;
use iref::IriBuf;
use json_ld::{
JsonContext,
NoLoader,
Document,
Object,
Reference
};
#[async_std::main]
async fn main() {
let context: JsonContext = JsonContext::new(None);
let doc = json::parse(r#"
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name"
},
"@id": "https://www.rust-lang.org",
"name": "Rust Programming Language"
}
"#).unwrap();
let expanded_doc = doc.expand(&context, &mut NoLoader).await.unwrap();
let name_property = Reference::Id(IriBuf::new("http://xmlns.com/foaf/0.1/name").unwrap());
for object in expanded_doc {
if let Object::Node(node) = object.as_ref() {
println!("node: {}", node.id().unwrap()); for name in node.get(&name_property) { println!("name: {}", name.as_str().unwrap());
}
}
}
}