Sha256: dea9dc6fc289bc960c023f906943a89dc91cec2e632f0c63ab89034f21da8601

Contents?: true

Size: 449 Bytes

Versions: 11

Compression:

Stored size: 449 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.kind_of?(Hash) ? @content.to_json : @content.to_s
      puts str_content
      @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

11 entries across 11 versions & 1 rubygems

Version Path
remocon-0.5.1 lib/remocon/normalizer/json_normalizer.rb
remocon-0.5.0 lib/remocon/normalizer/json_normalizer.rb
remocon-0.4.4 lib/remocon/normalizer/json_normalizer.rb
remocon-0.4.3 lib/remocon/normalizer/json_normalizer.rb
remocon-0.4.2 lib/remocon/normalizer/json_normalizer.rb
remocon-0.4.1 lib/remocon/normalizer/json_normalizer.rb
remocon-0.4.0 lib/remocon/normalizer/json_normalizer.rb
remocon-0.4.0.pre.1 lib/remocon/normalizer/json_normalizer.rb
remocon-0.3.1 lib/remocon/normalizer/json_normalizer.rb
remocon-0.3.0 lib/remocon/normalizer/json_normalizer.rb
remocon-0.2.0 lib/remocon/normalizer/json_normalizer.rb