从Ruby中的二维数组创建一个json数组

问题描述 投票:0回答:1

我有这样的二维数组:

[
  ["01fe237f804a5eff182dcded115c37d3", 0.0140845], 
  ["026e5f1f7f026bf3c763523206aa44bf", 0.03448275], 
  ["04a1c3c79773bd1ecc0372a991adc815", 0.04617604]
]

我想先创建一个哈希,然后将其转换为JSON,以便结果如下所示:

[{address: "01fe237f804a5eff182dcded115c37d3", value: 0.0140845},
{address: "026e5f1f7f026bf3c763523206aa44bf", value: 0.03448275},
{address: "04a1c3c79773bd1ecc0372a991adc815", value: 0.04617604}]
arrays ruby-on-rails json ruby hash
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.