Nesting error when trying to parse JSONfile

json, reddit, ruby

Solution

Try setting the max_nesting value:

result = JSON.parse(@response, :max_nesting => 100)

Problem

I'm trying to parse the JSON file of a Reddit thread with all it's comments. But when I try to parse the JSON I get a "in `parse': nesting of 20 is too deep " error. Below is the code i use: ``` #require 'net/http' #require 'rubygems' #require 'json' @response = Net::HTTP.get(URI.parse("http://www.reddit.com/r/AskReddit/comments/sjm1z/what_is_your_most_useless_talent/.json")) result = JSON.parse(@response) ``` Is there anyway I can get around this? It is not essential for me to have all the smaller subthreads parsed. Is there a way to set the nesting depth limit?

Original source