README.md in json-streamer-1.0.0 vs README.md in json-streamer-1.1.0

- old
+ new

@@ -1,14 +1,14 @@ # Json::Streamer -| Build status | | -| ------------ | - | +#### Ruby utility that supports JSON streaming allowing you to get data based on various criteria (key, nesting level, etc). + +| Branch | Build status | +| ------ | ------------ | | Release | [![Build Status](https://travis-ci.org/thisismydesign/json-streamer.svg?branch=release)](https://travis-ci.org/thisismydesign/json-streamer) [![Coverage Status](https://coveralls.io/repos/github/thisismydesign/json-streamer/badge.svg?branch=release)](https://coveralls.io/github/thisismydesign/json-streamer?branch=release) [![Gem Version](https://badge.fury.io/rb/json-streamer.svg)](https://badge.fury.io/rb/json-streamer) | | Development | [![Build Status](https://travis-ci.org/thisismydesign/json-streamer.svg?branch=master)](https://travis-ci.org/thisismydesign/json-streamer) [![Coverage Status](https://coveralls.io/repos/github/thisismydesign/json-streamer/badge.svg?branch=master)](https://coveralls.io/github/thisismydesign/json-streamer?branch=master) | -Ruby utility that supports JSON streaming allowing you to get data based on various criteria (key, nesting level, etc). - *If you've tried JSON streaming with other Ruby libraries before (e.g. [JSON::Stream](https://github.com/dgraham/json-stream), [Yajl::FFI](https://github.com/dgraham/yajl-ffi)):* This gem will basically spare you the need to define your own callbacks (i.e. implement an actual JSON parser using `start_object`, `end_object`, `key`, `value`, etc.). @@ -126,9 +126,29 @@ ``` Output: ```json {} +``` + +#### EventMachine-style input (since 1.1.0) + +```ruby +# Get a JsonStreamer object that provides access to the parser +# but does not start processing immediately +streamer = Json::Streamer::JsonStreamer.new + +streamer.get(nesting_level:1) do |object| + p object +end +``` + +Then later in your EventMachine handler: + +```ruby +def receive_data(data) + streamer.parser << data +end ``` Check the unit tests for more examples ([spec/streamer_spec.rb](spec/streamer_spec.rb)). ## Feedback