def write(data, output_io, options = {})
      options = {
        :mode => :compat
      }.merge!(options)

      if output_io
        # write json and return IO
        Oj.to_stream(output_io, data, options)
        output_io
      else
        # return json string
        string_io = StringIO.new
        Oj.to_stream(string_io, data, options)
        string_io.string
      end
    end
def write(data, output_io, options = {})
      options = {
        :mode => :compat
      }.merge!(options)

      if output_io
        # write json and return IO
        Oj.to_stream(output_io, data, options)
        output_io
      else
        # return json string
        string_io = StringIO.new
        Oj.to_stream(string_io, data, options)
        string_io.string
      end
    end
Writes objects to JSON using a streaming mechanism in Oj.

 If an IO is provided as +output_io+ then the encoded JSON will be written
 directly to it and returned from the method.

 If an IO is not provided (i.e. `nil`) then the encoded JSON {String} will
 be returned.

 @param  [Hash, Array, Object] data      the objects to encode as JSON
 @param  [IO]                  output_io the IO to write the encoded JSON
         to
 @param  [Hash]                options supplemental options to Oj; default
         is to set the +:mode+ option to +:compat+
 @return [IO, String]          an {IO} of encoded JSON is returned if it
 was provided as an argument, otherwise a JSON-encoded {String} is
 returned