Class: LLM::JSONAdapter::Oj
- Inherits:
-
JSONAdapter
- Object
- JSONAdapter
- LLM::JSONAdapter::Oj
- Defined in:
- lib/llm/json_adapter.rb
Overview
The LLM::JSONAdapter::Oj class provides a JSON adapter backed by the Oj gem.
Class Method Summary collapse
Class Method Details
.dump(obj, options = {}) ⇒ Object
96 97 98 99 |
# File 'lib/llm/json_adapter.rb', line 96 def self.dump(obj, = {}) require "oj" unless defined?(::Oj) ::Oj.dump(obj, .merge(mode: :compat)) end |
.load(string, options = {}) ⇒ Object
103 104 105 106 |
# File 'lib/llm/json_adapter.rb', line 103 def self.load(string, = {}) require "oj" unless defined?(::Oj) ::Oj.load(string, .merge(mode: :compat, symbol_keys: false, symbolize_names: false)) end |
.parser_error ⇒ Object
110 111 112 113 |
# File 'lib/llm/json_adapter.rb', line 110 def self.parser_error require "oj" unless defined?(::Oj) [::Oj::ParseError, ::EncodingError] end |