Struct json_ld::object::node::properties::Properties
source[−]Expand description
Properties of a node object, and their associated objects.
Example
use json_ld::{context, Document, NoLoader};
use serde_json::Value;
let doc: Value = serde_json::from_str(
r#"
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name"
},
"@id": "https://www.rust-lang.org",
"name": "Rust Programming Language"
}
"#,
)
.unwrap();
let mut loader = NoLoader::<Value>::new();
let rt = tokio::runtime::Runtime::new().unwrap();
let expanded_doc = rt.block_on(doc
.expand::<context::Json<Value>, _>(&mut loader)).unwrap();
let node = expanded_doc.into_iter().next().unwrap().into_indexed_node().unwrap();
for (property, objects) in node.properties() {
assert_eq!(property, "http://xmlns.com/foaf/0.1/name");
for object in objects {
// do something
}
}
Implementations
Checks if the given property is associated to any object.
Returns an iterator over all the objects associated to the given property.
Get one of the objects associated to the given property.
If multiple objects are found, there are no guaranties on which object will be returned.
Associate the given object to the node through the given property.
Associate all the given objects to the node through the given property.
Returns an iterator over the properties and their associated objects.
Trait Implementations
impl<J: PartialEq + JsonHash, T: PartialEq + Id> PartialEq<Properties<J, T>> for Properties<J, T>
impl<J: PartialEq + JsonHash, T: PartialEq + Id> PartialEq<Properties<J, T>> for Properties<J, T>
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.