【问题标题】:JSON Nesting Too Deep (Using OJ)JSON 嵌套太深(使用 OJ)
【发布时间】:2013-02-28 04:41:34
【问题描述】:

问题:

JSON::NestingError: nesting of 101 is too deep

我尝试将:max_nesting => 120 添加到我的JSON.parse 行,但无济于事。

然后切换到 OJ 看看是否会改变它。

有什么想法吗?

【问题讨论】:

  • 你真的有101层嵌套吗?你真的需要它吗?
  • 我正在大规模调用外部api。我看不出有什么办法……

标签: ruby-on-rails json parsing


【解决方案1】:

使用 max_nesting 选项调用 JSON.parse。它对我有用。

> o = JSON.parse(File.read(Rails.root.join("deep.json")))
JSON::NestingError: nesting of 101 is too deep
> o = JSON.parse(File.read(Rails.root.join("deep.json")),max_nesting: 150)
# { Big ol' deeply nested hash }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-10
    • 1970-01-01
    • 2015-01-27
    • 1970-01-01
    相关资源
    最近更新 更多