fn json_str_to_attributes()

in src/data.rs [682:700]


fn json_str_to_attributes(s: &str) -> Result<HashMap<String, AttributeValue>, serde_json::Error> {
    debug!(
        "Trying to convert from standard JSON received from command line into attributes: {}",
        s
    );

    // In this line we assume that 1st element of JSON is not an array.
    // i.e. this type annotation assumes single JSON element:
    //     {"a": "val", "b": "yay"}
    // on the other hand, cannot be used for JSON begins with array like:
    //     [ {"a": "val"}, {"b": "yay"} ]
    let hashmap: HashMap<String, JsonValue> = serde_json::from_str(s)?; // unknown JSON structure
    debug!("JSON -> HashMap: {:?}", hashmap);

    let result = convert_jsonval_to_attrvals_in_hashmap_val(hashmap);
    debug!("JSON has been converted to AttributeValue(s): {:?}", result);

    Ok(result)
}