avsej / gson.rb

Ruby wrapper for google-gson library
Apache License 2.0
10 stars 5 forks source link

Real streaming API #1

Open avsej opened 11 years ago

avsej commented 11 years ago

It should be possible to create instance of the Gson::Decoder and feed the chunks of JSON and it should execute callbacks when the object is ready.

decoder = Gson::Decoder.new
decoder.on_document do |doc|
  puts doc.inspect
end
decoder.write('{"foo')
decoder.write('":"bar"},{"num":')
#=> {"foo" => "bar"}
decoder.write('1}')
#=> {"num" => 1}