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.165.1 lib/aws-sdk-core/json.rb
aws-sdk-core-3.165.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.164.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.163.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.162.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.161.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.160.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.159.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.158.1 lib/aws-sdk-core/json.rb
aws-sdk-core-3.158.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.157.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.156.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.155.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.154.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.153.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.152.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.151.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.150.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.149.0 lib/aws-sdk-core/json.rb
aws-sdk-core-3.148.0 lib/aws-sdk-core/json.rb