Sha256: daf1489e0eb5dd61e4d57d558c46ea2214a03093360e374b1c0d47d294f51c2d

Contents?: true

Size: 883 Bytes

Versions: 133

Compression:

Stored size: 883 Bytes

Contents

# frozen_string_literal: true

require 'json'
require_relative 'json/builder'
require_relative 'json/error_handler'
require_relative 'json/handler'
require_relative 'json/parser'
require_relative 'json/json_engine'
require_relative 'json/oj_engine'

module Aws
  # @api private
  module Json
    class ParseError < StandardError
      def initialize(error)
        @error = error
        super(error.message)
      end

      attr_reader :error
    end

    class << self
      def load(json)
        ENGINE.load(json)
      end

      def load_file(path)
        load(File.open(path, 'r', encoding: 'UTF-8', &:read))
      end

      def dump(value)
        ENGINE.dump(value)
      end

      private

      def select_engine
        require 'oj'
        OjEngine
      rescue LoadError
        JSONEngine
      end
    end

    # @api private
    ENGINE = select_engine
  end
end

Version data entries

133 entries across 133 versions & 1 rubygems

Version Path
aws-sdk-core-3.147.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.146.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.145.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.144.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.143.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.142.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.141.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.140.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.139.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.138.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.137.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.136.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.135.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.134.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.133.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.132.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.131.6 lib/aws-sdk-core/json.rb
aws-sdk-core-3.131.5 lib/aws-sdk-core/json.rb
aws-sdk-core-3.131.4 lib/aws-sdk-core/json.rb
aws-sdk-core-3.131.3 lib/aws-sdk-core/json.rb