我如何使用 savon 嵌套数组属性!哈希?

How do I use savon nested array attributes! hash?

我正在使用 Ruby Savon,我必须创建一个请求,其中包含一个包含属性的数组。 我的问题是如何在每个子数组中添加一个属性。

  <persons>
    <person id=1>
      <firstName>JOHN</firstName>                  
    </person>
    <person id=2>
      <firstName>ANNIE</firstName>
    </person>
  </persons>

我也尝试过将属性放入数组,但没有成功。

{
  persons: {
    person:  [ { firstName: "JOHN"}, { firstName: "ANNIE" } ], 
    :attributes! => { :person=> [ { id: "1" }, { id: "2" } ] }
  }
}.to_soap_xml
{
     persons: {
        person:  [ { firstName: "JOHN", :@id => 1}, { firstName: "ANNIE", :@id => 2 } ]
     }
}