Class: LLM::JSONAdapter::Oj
- Inherits:
-
LLM::JSONAdapter
- Object
- LLM::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
70 71 72 73 |
# File 'lib/llm/json_adapter.rb', line 70 def self.dump(obj, = {}) require "oj" unless defined?(::Oj) ::Oj.dump(obj, .merge(mode: :compat)) end |
.load(string, options = {}) ⇒ Object
77 78 79 80 |
# File 'lib/llm/json_adapter.rb', line 77 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
84 85 86 87 |
# File 'lib/llm/json_adapter.rb', line 84 def self.parser_error require "oj" unless defined?(::Oj) [::Oj::ParseError, ::EncodingError] end |