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
121 122 123 124 |
# File 'lib/llm/json_adapter.rb', line 121 def self.dump(obj, = {}) require "oj" unless defined?(::Oj) ::Oj.dump(normalize(obj), .merge(mode: :compat)) end |
.load(string, options = {}) ⇒ Object
128 129 130 131 |
# File 'lib/llm/json_adapter.rb', line 128 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
136 137 138 139 |
# File 'lib/llm/json_adapter.rb', line 136 def self.parser_error require "oj" unless defined?(::Oj) [::Oj::ParseError, ::EncodingError] end |