Sha256: 325799a8353cd53f8aaf702fd244da0fb57091f701bfded4f673b80635d45fb1

Contents?: true

Size: 423 Bytes

Versions: 1

Compression:

Stored size: 423 Bytes

Contents

# frozen_string_literal: true

module Remocon
  class JsonNormalizer < Remocon::Normalizer
    def self.respond_symbol
      Remocon::Type::JSON
    end

    def validate
      str_content = @content.is_a?(Hash) ? @content.to_json : @content.to_s
      @json = JSON.parse(str_content).to_json
    rescue JSON::ParserError => e
      raise ValidationError, e.message
    end

    def normalize
      @json
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
remocon-0.1.0 lib/remocon/normalizer/json_normalizer.rb