Sha256: ff112f028eedccf164a044ae4e6eecf5007870573e5453e7005d34b971d65a83

Contents?: true

Size: 535 Bytes

Versions: 4

Compression:

Stored size: 535 Bytes

Contents

# frozen_string_literal: true

require 'multi_json'

module Acfs
  module Middleware
    # A middleware to encore request data using JSON.
    #
    class JSON < Serializer
      def mime
        ::Mime[:json]
      end

      def encode(data)
        ::MultiJson.dump(data)
      end

      def decode(body)
        ::MultiJson.load(body)
      rescue ::MultiJson::ParseError => e
        raise ::JSON::ParserError.new(e)
      end
    end

    # @deprecated
    JsonDecoder = JSON

    # @deprecated
    JsonEncoder = JSON
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acfs-2.0.0 lib/acfs/middleware/json.rb
acfs-1.7.0 lib/acfs/middleware/json.rb
acfs-1.6.0 lib/acfs/middleware/json.rb
acfs-1.5.1 lib/acfs/middleware/json.rb