fn into_value()

in confidence/src/models.rs [75:118]


    fn into_value(self, schema: &Option<FlagSchema>) -> StructValue {
        if let Some(schema) = schema {
            let schema = &schema.schema;
            match self {
                Some(value) => {
                    if let Value::Object(value_map) = value {
                        let new_map: HashMap<String, ConfidenceValue> = value_map
                            .into_iter()
                            .map(|(key, value)| {
                                let converted_value = match schema[&key].clone() {
                                    SchemaType::BoolType => ConfidenceValue::Bool(
                                        value.as_bool().unwrap_or_default(),
                                    ),
                                    SchemaType::IntType => {
                                        ConfidenceValue::Int(value.as_i64().unwrap_or_default())
                                    }
                                    SchemaType::DoubleType => ConfidenceValue::Float(
                                        value.as_f64().unwrap_or_default(),
                                    ),
                                    SchemaType::StringType => ConfidenceValue::String(
                                        value.as_str().unwrap_or_default().to_string(),
                                    ),
                                    SchemaType::StructType(struct_value) => {
                                        ConfidenceValue::Struct(Some(value).into_value(&Some(
                                            FlagSchema {
                                                schema: *struct_value,
                                            },
                                        )))
                                    }
                                };
                                (key, converted_value)
                            })
                            .collect();
                        StructValue { fields: new_map }
                    } else {
                        StructValue::default()
                    }
                }
                None => StructValue::default(),
            }
        } else {
            StructValue::default()
        }
    }