Module: OandaAPI::Streaming::Adapters::Yajl

Extended by:
Yajl
Included in:
Yajl
Defined in:
lib/oanda_api/streaming/adapters/yajl.rb

Overview

Can be used if the ruby engine (RUBY_ENGINE) is NOT jruby. Uses the yajl-ruby gem. Handles streams of multiple JSON objects that may or may not be delimited with whitespace.

Instance Method Summary collapse

Instance Method Details

#parse(string) ⇒ Array<Hash>

Deserializes a stream of JSON objects.

Parameters:

  • string (String)

    serialized json.

Returns:

  • (Array<Hash>)

    an array of hashes.



15
16
17
18
19
# File 'lib/oanda_api/streaming/adapters/yajl.rb', line 15

def parse(string)
  results = []
  parser.parse(string) { |hash| results << hash }
  results
end