Module: OandaAPI::Streaming::Adapters::Gson

Extended by:
Gson
Included in:
Gson
Defined in:
lib/oanda_api/streaming/adapters/gson.rb

Overview

Can be used if the ruby engine (RUBY_ENGINE) is jruby. Uses the gson 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/gson.rb', line 15

def parse(string)
  string.strip!
  return [] if string.empty?
  [parser.decode(string)].flatten
end