Skip to content

"with_list_parse_key" environment parser does not support vector field #648

Open
@TAYTS

Description

@TAYTS

Not sure if I doing it wrongly or misunderstand the source code, the with_list_parse_key option is creating a map that will be used to check if a field should use list parser. In the case of vector of struct that contains vector field it is not possible to specify the key unless we specify all the possible index.

struct Nested {
    pub keys: Vec<String>,
}

struct Config {
    pub nested: Vec<Nested>
}

let env_source = Environment::with_prefix("server_config")
        .list_separator(",")
        // note: need to list all the possible index
        .with_list_parse_key("nested[0].keys")
        .with_list_parse_key("nested[1].keys")
        .try_parsing(true);

Is this the expected behaviour or could it be possible to support key like nested[*].keys?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions