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
64 65 66 67 |
# File 'lib/llm/json_adapter.rb', line 64 def self.dump(obj, = {}) require "oj" unless defined?(::Oj) ::Oj.dump(obj, .merge(mode: :compat)) end |
.load(string, options = {}) ⇒ Object
71 72 73 74 |
# File 'lib/llm/json_adapter.rb', line 71 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
78 79 80 81 |
# File 'lib/llm/json_adapter.rb', line 78 def self.parser_error require "oj" unless defined?(::Oj) [::Oj::ParseError, ::EncodingError] end |