Class: Decidim::Admin::Import::Readers::JSON

Inherits:
Base
  • Object
show all
Defined in:
decidim-admin/lib/decidim/admin/import/readers/json.rb

Overview

Imports any exported JSON file to local objects. It transforms the import data using the creator into the final target objects.

Constant Summary collapse

MIME_TYPE =
"application/json"

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Decidim::Admin::Import::Readers::Base

Instance Method Details

#read_rowsObject


14
15
16
17
18
19
20
# File 'decidim-admin/lib/decidim/admin/import/readers/json.rb', line 14

def read_rows
  json_string = File.read(file)
  ::JSON.parse(json_string).each_with_index do |row, index|
    yield row.keys, index if index.zero?
    yield row.values, index + 1
  end
end