feat: Node::maybe_object
This commit is contained in:
parent
45c5ea69a6
commit
59e8b298f5
1 changed files with 9 additions and 2 deletions
|
@ -110,8 +110,15 @@ impl Node<serde_json::Value>{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn object(x: serde_json::Value) -> Self {
|
pub fn object(x: impl super::Base) -> Self {
|
||||||
Node::Object(Box::new(x))
|
Node::Object(Box::new(x.underlying_json_object()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn maybe_object(x: Option<impl super::Base>) -> Self {
|
||||||
|
match x {
|
||||||
|
Some(x) => Node::Object(Box::new(x.underlying_json_object())),
|
||||||
|
None => Node::Empty,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn array(x: Vec<impl super::Base>) -> Self {
|
pub fn array(x: Vec<impl super::Base>) -> Self {
|
||||||
|
|
Loading…
Reference in a new issue