我正在使用 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 } ]
}
}
关于ruby - 我如何使用 savon 嵌套数组属性!哈希?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28156910/