fn parse_node_object(
    node_name: &String,
    contents: &Map<String, Value>,
) -> Result<NodeHierarchy, Error> {
    let mut properties: Vec<Property> = Vec::new();
    let mut children: Vec<NodeHierarchy> = Vec::new();
    for (name, value) in contents.iter() {
        match value {
            serde_json::Value::Object(obj) => match fetch_object_histogram(obj) {
                Some(histogram_vec) => {
                    properties.push(parse_histogram(name, histogram_vec)?);
                }
                None => {
                    let child_node = parse_node_object(name, obj)?;
                    children.push(child_node);
                }
            },
            serde_json::Value::Bool(_) => {
                // TODO(37140): Deserialize booleans when supported.
                bail!("Booleans are not part of the diagnostics schema.");
            }
            serde_json::Value::Number(num) => {
                properties.push(parse_number(name, num)?);
            }
            serde_json::Value::String(string) => {
                let string_property = Property::String(name.to_string(), string.to_string());
                properties.push(string_property);
            }
            serde_json::Value::Array(vec) => {
                properties.push(parse_array(name, vec)?);
            }
            serde_json::Value::Null => {
                bail!("Null isn't an existing part of the diagnostics schema.");
            }
        }
    }

    Ok(NodeHierarchy::new(node_name, properties, children))
}
/// Creates a NodeHierarchy from a serde_json Object map, evaluating each of
/// the entries in the map and parsing them into their relevant Inspect in-memory
/// representation.
Creates a NodeHierarchy from a serde_json Object map, evaluating each of
the entries in the map and parsing them into their relevant Inspect in-memory
representation.
Creates a NodeHierarchy from a serde_json Object map evaluating each of the entries in the map and parsing them into their relevant Inspect in - memory representation .
fn parse_node_object(
    node_name: &String,
    contents: &Map<String, Value>,
) -> Result<NodeHierarchy, Error> {
    let mut properties: Vec<Property> = Vec::new();
    let mut children: Vec<NodeHierarchy> = Vec::new();
    for (name, value) in contents.iter() {
        match value {
            serde_json::Value::Object(obj) => match fetch_object_histogram(obj) {
                Some(histogram_vec) => {
                    properties.push(parse_histogram(name, histogram_vec)?);
                }
                None => {
                    let child_node = parse_node_object(name, obj)?;
                    children.push(child_node);
                }
            },
            serde_json::Value::Bool(_) => {
                // TODO(37140): Deserialize booleans when supported.
                bail!("Booleans are not part of the diagnostics schema.");
            }
            serde_json::Value::Number(num) => {
                properties.push(parse_number(name, num)?);
            }
            serde_json::Value::String(string) => {
                let string_property = Property::String(name.to_string(), string.to_string());
                properties.push(string_property);
            }
            serde_json::Value::Array(vec) => {
                properties.push(parse_array(name, vec)?);
            }
            serde_json::Value::Null => {
                bail!("Null isn't an existing part of the diagnostics schema.");
            }
        }
    }
    Ok(NodeHierarchy::new(node_name, properties, children))
}
fn parse_node_object ( node_name : & String , contents : & Map < String , Value > , ) -> Result < NodeHierarchy , Error > { let mut properties : Vec < Property > = Vec :: new ( ) ; let mut children : Vec < NodeHierarchy > = Vec :: new ( ) ; for ( name , value ) in contents . iter ( ) { match value { serde_json :: Value :: Object ( obj ) => match fetch_object_histogram ( obj ) { Some ( histogram_vec ) => { properties . push ( parse_histogram ( name , histogram_vec ) ? ) ; } None => { let child_node = parse_node_object ( name , obj ) ? ; children . push ( child_node ) ; } } , serde_json :: Value :: Bool ( _ ) => { // TODO(37140): Deserialize booleans when supported. bail ! ( " " ) ; } serde_json :: Value :: Number ( num ) => { properties . push ( parse_number ( name , num ) ? ) ; } serde_json :: Value :: String ( string ) => { let string_property = Property :: String ( name . to_string ( ) , string . to_string ( ) ) ; properties . push ( string_property ) ; } serde_json :: Value :: Array ( vec ) => { properties . push ( parse_array ( name , vec ) ? ) ; } serde_json :: Value :: Null => { bail ! ( " " ) ; } } } Ok ( NodeHierarchy :: new ( node_name , properties , children ) ) }
Creates a NodeHierarchy from a serde_json Object map, evaluating each of
the entries in the map and parsing them into their relevant Inspect in-memory
representation.
Creates a NodeHierarchy from a serde_json Object map evaluating each of the entries in the map and parsing them into their relevant Inspect in - memory representation .
node_name
&String
contents
&Map<String, Value>