fn attrval_to_jsonval()

in src/data.rs [1350:1381]


fn attrval_to_jsonval(attrval: &AttributeValue) -> JsonValue {
    let unsupported: &str = "<<<JSON output doesn't support this type attributes>>>";
    //  following list of if-else statements would be return value of this function.
    if let Some(v) = &attrval.s {
        serde_json::to_value(v).unwrap()
    } else if let Some(v) = &attrval.n {
        str_to_json_num(v)
    } else if let Some(v) = &attrval.bool {
        serde_json::to_value(v).unwrap()
    } else if let Some(vs) = &attrval.ss {
        serde_json::to_value(vs).unwrap()
    } else if let Some(vs) = &attrval.ns {
        vs.iter().map(|v| str_to_json_num(v)).collect()
    }
    // In List (L) type, each element is a DynamoDB AttributeValue (e.g. {"S": "xxxx"}). recursively apply this method to elements.
    else if let Some(vlst) = &attrval.l {
        vlst.iter().map(|v| attrval_to_jsonval(v)).collect()
    } else if let Some(vmap) = &attrval.m {
        attrval_to_json_map(vmap)
    } else if attrval.null.is_some() {
        serde_json::to_value(()).unwrap()
    }
    // Binary (B) and BinarySet (BS) attributes are not supported to display in JSON output format.
    else if attrval.b.is_some() || attrval.bs.is_some() {
        serde_json::to_value(unsupported).unwrap()
    } else {
        panic!(
            "DynamoDB AttributeValue is not in valid status: {:#?}",
            &attrval
        );
    }
}