A limitation I have run into in the past in using the yajl-ruby Gem for parsing large JSON documents is the case where I need to parse a very large array of objects but would like to have a callback fired on each object as opposed to the on_parse_complete callback at the end. I had been using a hacked-together patch personally for a while, but figured it made sense to push this to the main project.
This patch adds a process_nested option to theYajl::Parser.new call that will call a on_parse_nested (if set) callback when every object / array is parsed from the JSON along with the depth the object was parsed at. An additional option to the Yajl::Parser.new call, nested_depth, may be called to declare at what maximum depth the callback will be fired; 0, the default, will fire the callback on every object.
The on_parse_nested Proc receives two arguments, obj and depth. obj is the same object received by the on_parse_complete callback, and depth is the depth at which the nested object was parsed.
Let me know if you have any questions, or if you feel this doesn't make sense for the yajl-ruby project.
I need to finally commit this to Github so I can access this elsewher…
…e and finally fix / implement this feature.
Pushing the process_nested option and very limited spec tests.
We probably don't need the process_nested boolean here if we can just infer that they want to use the feature based on if the nested_depth key exists in the options hash?
Replace 'process_nested' option with test of 'on_parse_nested' (issue #…
It uses the fact of availability 'on_parse_nested' callback instead of
'process_nested' option. This patch also remove trailing spaces introduces
HI all, @brianmario maybe my patch will help to accept this feature?