pub struct JsonRef { /* private fields */ }
Expand description
Main struct that holds configuration for a JSONScheama derefferencing.
Instantiate with
use jsonref::JsonRef;
let jsonref = JsonRef::new();
Configuration is done through the set_
methods on the struct.
Implementations§
Source§impl JsonRef
impl JsonRef
Sourcepub fn set_reference_key(&mut self, reference_key: &str)
pub fn set_reference_key(&mut self, reference_key: &str)
Set a key to store the data that the $ref
replaced.
This example uses __reference__
as the key.
use serde_json::json;
let mut input = json!(
{"properties": {"prop1": {"title": "name"},
"prop2": {"$ref": "#/properties/prop1", "title": "old_title"}}
}
);
let expected = json!(
{"properties": {"prop1": {"title": "name"},
"prop2": {"title": "name", "__reference__": {"title": "old_title"}}}
}
);
let mut jsonref = JsonRef::new();
jsonref.set_reference_key("__reference__");
jsonref.deref_value(&mut input).unwrap();
assert_eq!(input, expected)
Sourcepub fn deref_value(&mut self, value: &mut Value) -> Result<(), Error>
pub fn deref_value(&mut self, value: &mut Value) -> Result<(), Error>
deref a serde_json value directly. Uses the current working directory for any relative refs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JsonRef
impl RefUnwindSafe for JsonRef
impl Send for JsonRef
impl Sync for JsonRef
impl Unpin for JsonRef
impl UnwindSafe for JsonRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more