当我想在板上使用时,我遇到了json格式的问题。在我的json文件中,每个信息都有双括号,而我应该只有括号,是否可以删除其中一个?
代码:
elsif (params[:which] == "BigSize")
res= []
# PrintType.where("width > 70").where("width <= 120").where("height > 118.9").where("height <= 150").pluck('DISTINCT artwork_id')
big = PrintType.where("width > 70").where("width <= 120").where("height > 118.9").where("height <= 150").pluck('DISTINCT artwork_id')
res << [big]
render :json => res.to_json(include: { :images => { :except => :img_orig } })
结果:here
您正在将数组推入数组res << [big]
要停止创建两个括号,只需编写res << big
或者如果它是必要的另一个原因在将res
转换为json之前将其展平