class Decidim::Exporters::JSON

Exports a JSON version of a provided hash, given a collection and a Serializer.

Public Instance Methods

export() click to toggle source

Public: Generates a JSON representation of a collection and a Serializer.

Returns an ExportData with the export.

# File lib/decidim/exporters/json.rb, line 14
def export
  data = ::JSON.pretty_generate(@collection.map do |resource|
    @serializer.new(resource).serialize
  end)

  ExportData.new(data, "json")
end