Module: CsvJsonConverter
- Defined in:
- lib/csv_json_converter.rb,
lib/csv_json_converter/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
-
.to_json(input, separator = ',') ⇒ Object
Your code goes here…
Class Method Details
.to_json(input, separator = ',') ⇒ Object
Your code goes here…
9 10 11 12 13 14 15 16 17 |
# File 'lib/csv_json_converter.rb', line 9 def self.to_json(input, separator=',') for_csv = CSV.parse(input,:col_sep => separator,headers: true, header_converters: :symbol) # treat first row as headers if the caller didn't provide them arr_to_json = for_csv.map(&:to_h).to_json arr_to_json end |