我有一个看起来像这样的数组。
[{"EntryId"=>"2", "Field1"=>"National Life Group","DateCreated"=>"2010-07-30 11:00:14", "CreatedBy"=>"tristanoneil"},
{"EntryId"=>"3", "Field1"=>"Barton Golf Club", "DateCreated"=>"2010-07-30 11:11:20", "CreatedBy"=>"public"},
{"EntryId"=>"4", "Field1"=>"PP&D Brochure Distribution", "DateCreated"=>"2010-07-30 11:11:20", "CreatedBy"=>"public"},
{"EntryId"=>"5", "Field1"=>"Prime Renovation Group, DreamMaker Bath & Kitchen", "DateCreated"=>"2010-07-30 11:11:21", "CreatedBy"=>"public"}
]
我该如何遍历这个数组,以便我可以指定要打印出哪个字段并获取其值,这样我就可以做类似以下的事情。
puts EntryId.value
entry["EntryId"]
时,我得到了无法将字符串转换为整数(TypeError)
的错误。 - Sparkplug