0

Lets say I have a yaml file like this:

country.yaml

country:
  India:
    State:"Delhi"
  USA:
    State:"Texas"

After I load yaml into my ts code:

const variable = fs.readFileSync('./path/country.yaml', 'utf-8');
const v2 = yaml.load(variable);

Can I fetch a config value using a variable like this:

const y = v2.country.insert-variable.State;

Is it possible to insert a variable and fetch config like this? and how?

I tried with no success:

const y = v2.country.$(insert-variable).State;

and

const y = v2.country.{{insert-variable}}.State;

0 Answers0