From: Jamis Buck Date: 2004-09-08T06:44:49+09:00 Subject: Re: yaml nuby question - duplicate keys Daniel Berger wrote: > Hi all, > > Ruby 1.8.2 > > I'd like to have a config file that looks like this: > > # test.yml > foo: > user: usr1 > password: pwd1 > foo: > user: usr2 > password: pwd2 > bar: > user: usr3 > password: pwd3 > > But, I try a simple YAML.load(File.open("test.yml") I lose one of the > entries, because it loads it as a Hash which, of course, does not > allow for duplicate keys. > > Is there a way I can keep this kind of config file and still use YAML? > I looked at the various parse() options, but it started to go over my > head at that point. You can try turning into an array, instead of a hash: - foo: user: usr1 password: pwd1 - foo: user: user2 password: pwd2 Then you'd access it like: data[0]['foo']['user'] instead of data['foo']['user'] Hope that helps, Jamis > > Thanks. > > Dan > > . > -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis "I use octal until I get to 8, and then I switch to decimal."