Function parse_json_array

Source
pub fn parse_json_array<Target>(s: &str) -> Result<Vec<Target>, ParseError>
where Target: FromStr,
Expand description

Tries to parse a json array, you can insert a type to be casted on each item.

Example: ‘[“4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b”, “4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b”]’ Tries to parse a JSON array of hash strings into a vector of the target type.

The target type must implement Deserialize and can be converted from a hash string. By default, it will parse into Hash256, but you can specify any other compatible type.

Example:

let hashes: Vec<sha256::Hash> =
    parse_json_array(r#"["4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"]"#)
        .unwrap();