我有以下嵌套哈希:发送红宝石后嵌套哈希
$installation_settings = {
:lat => "43.107044",
:lon => "25.194757",
:country => "Poland",
:collector_installation => {
:people => 3,
:deviation_from_s => 5,
:solar_collector_id => 1,
:collectors_number => 2,
:monthly_water_consumption => 6000,
:gas_price => 0.09,
:electricity_price => 0.87
}
}
其中我试图通过邮局用红宝石派:
url = "someURL"
uri = URI(url)
res = Net::HTTP.post_form(uri, $installation_settings)
puts res.body
的Net :: HTTP.post_form只允许发送简单的哈希(没有嵌套),所以我最终得到反斜杠的字符串。
我该如何发送?
通常这个数据被发送为JSON,但目前还没有足够的信息来表明,在这种特殊情况下以适当的方式。 – mudasobwa
我发现像这样['HTTParty'](https://github.com/jnunemaker/httparty)这样简单的事情,gem做得非常出色。 – engineersmnky