You can have hashes within hashes.
people = { 'xml' => { # w w w.ja va2s . co m 'name' => 'XML', 'age' => 3, 'gender' => 'male', 'favorite painters' => ['Java', 'C', 'C++'] }, 'json' => { 'name' => 'JSON', 'age' => 5, 'gender' => 'female' } } puts people['xml']['age'] puts people['json']['gender'] p people['json'] puts people['xml']['favorite painters'].length puts people['xml']['favorite painters'].join(", ")