Sha256: c2959f71787f10a2bafec9780ced856bfa8d5aa0ebd58e0abcc2abb89b0fcaba

Contents?: true

Size: 561 Bytes

Versions: 8

Compression:

Stored size: 561 Bytes

Contents

module Alf
  class Reader
    #
    # Implements Alf::Reader contract for reading JSON input.
    #
    class JSON < Reader

      def self.mime_type
        "application/json"
      end

      def each
        return to_enum unless block_given?
        require 'json'
        p = ::JSON.parse(input_text, create_additions: false)
        p = [p] if TupleLike===p
        p.each do |t|
          yield Support.symbolize_keys(t)
        end
      end

      Alf::Reader.register(:json, [".json"], self)
    end # class JSON
  end # class Reader
end # module Alf

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/reader/json.rb
alf-core-0.16.2 lib/alf/reader/json.rb
alf-core-0.16.1 lib/alf/reader/json.rb
alf-core-0.16.0 lib/alf/reader/json.rb
alf-core-0.15.0 lib/alf/reader/json.rb
alf-core-0.14.0 lib/alf-io/alf/reader/json.rb
alf-core-0.13.1 lib/alf-io/alf/reader/json.rb
alf-core-0.13.0 lib/alf-io/alf/reader/json.rb