Class: Mysql2xxxx::JSON

Inherits:
Writer
  • Object
show all
Defined in:
lib/mysql2xxxx/writer/json.rb

Constant Summary

Constants inherited from Writer

Writer::ICONV_FROM, Writer::ICONV_TO, Writer::MYSQL_CHARSET

Instance Attribute Summary

Attributes inherited from Writer

#config

Instance Method Summary collapse

Methods inherited from Writer

#close, #dbh, #initialize, #keys, #last_statement, #recode_as_utf8, #result, #stream_arrays, #stream_hashes, #to_path, #to_s, #to_stdout

Constructor Details

This class inherits a constructor from Mysql2xxxx::Writer

Instance Method Details

#to_file(f) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mysql2xxxx/writer/json.rb', line 5

def to_file(f)
  first = true
  f.write '['
  stream_hashes do |hsh|
    if first
      first = false
    else
      f.write ','
    end
    f.write ::MultiJson.encode(hsh)
  end
  f.write ']'
  nil
end