issue with render json for array

前端 未结 1 1375
既然无缘
既然无缘 2021-01-26 15:24

I have this array coming from my server. Which is returned like this when i use puts:

formatted_total_price
£66.00
formatted_total_price
&am         


        
相关标签:
1条回答
  • 2021-01-26 16:18
    a = Array.new
    
    price1.each do |p|
        a.merge({p[0] => p[1]})
    end
    
    render json: a.to_json
    

    or simply you can do

    price1.map{|a| { a[0] => a[1] } }.to_json
    
    0 讨论(0)
提交回复
热议问题