Sha256: 52fc046bf32b4d0d27d2c70c87a2cd0bd81eacf6b7d7c9e7f9c91c0eaa46fb19
Contents?: true
Size: 671 Bytes
Versions: 18
Compression:
Stored size: 671 Bytes
Contents
# frozen_string_literal: true require "oj" module MuchRails; end # MuchRails::JSON is an adapter for encoding and decoding JSON values. # It uses Oj to do the work: https://github.com/ohler55/oj#-gem module MuchRails::JSON InvalidError = Class.new(TypeError) def self.default_mode :strict end def self.encode(obj, **options) options[:mode] ||= default_mode ::Oj.dump(obj, options) end def self.decode(json, **options) options[:mode] ||= default_mode ::Oj.load(json, options) rescue ::Oj::ParseError => ex error = InvalidError.new("Oj::ParseError: #{ex.message}") error.set_backtrace(ex.backtrace) raise error end end
Version data entries
18 entries across 18 versions & 1 rubygems