class Csv2Psql::JsonHelper

Json Helper

Constants

BASE_DIR

Public Class Methods

load_file(path) click to toggle source
# File lib/csv2psql/helpers/json_helper.rb, line 11
def load_file(path)
  # Load input file
  raw = IO.read(path)

  # Try to parse json from loaded data
  begin
    return MultiJson.load(raw)
  rescue Exception => e # rubocop:disable RescueException
    log_exception(e)
    raise e
  end
  nil
end
log_exception(e) click to toggle source
# File lib/csv2psql/helpers/json_helper.rb, line 25
def log_exception(e)
  puts 'Invalid json, see error.txt'
  File.open('error.txt', 'wt') { |f| f.write(e.to_s) }
end