我将Ruby on Rails应用程序从3.0迁移到3.1,并遇到了JSON后端更改中的一些问题。在Ruby on Rails应用程序中设置json max_nesting选项
该行ActiveSupport::JSON.decode(some_variable)
给我MultiJson :: DecodeError nesting of 20 is too deep
。 我试图解码的变量实际上是嵌套的(最多29级)。
使用:max_nesting
选项('Nesting too deep' error while retrieving JSON using HTTParty)应该可以更改最大嵌套层次,但这似乎不起作用。
ActiveSupport::JSON.decode(some_variable, :max_nesting => false)
和ActiveSupport::JSON.decode(some_variable, :max_nesting => 100)
都会导致相同的错误。
有没有办法通过max_nesting
选项或将其设置为应用程序范围?
使用'JSON.parse(some_variable,:max_nesting => false)'解决了问题 – bmesuere