Created
May 19, 2017 15:55
-
-
Save thisismydesign/66a686b3fe80f2cb8a2a453ac1ffd3e4 to your computer and use it in GitHub Desktop.
How to write a JSON srteamer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@aggregator # what to yield | |
@current_nesting_level # when to yield | |
@parser.start_object do | |
@current_nesting_level += 1 | |
end | |
@parser.end_object do | |
if yield_object?(yield_nesting_level) | |
yield @aggregator[@current_nesting_level].clone | |
@aggregator = {} | |
end | |
@current_nesting_level -= 1 | |
end | |
@parser.key do | |
# build @agrregator | |
end | |
@parser.value do | |
# build @agrregator | |
end | |
def yield_object?(yield_nesting_level) | |
@current_nesting_level.eql? yield_nesting_level | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment