Class: LLM::JSONAdapter::JSON
- Inherits:
-
JSONAdapter
- Object
- JSONAdapter
- LLM::JSONAdapter::JSON
- Defined in:
- lib/llm/json_adapter.rb
Overview
The LLM::JSONAdapter::JSON class provides a JSON adapter backed by the standard library JSON module.
Class Method Summary collapse
Class Method Details
.dump(obj, state = nil, **options) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/llm/json_adapter.rb', line 75 def self.dump(obj, state = nil, **) require "json" unless defined?(::JSON) pretty = .delete(:pretty) || false if ::JSON::State === state if pretty ::JSON.pretty_generate normalize(obj), state else ::JSON.generate normalize(obj), state end elsif state if pretty ::JSON.pretty_generate normalize(obj), state, ** else ::JSON.dump normalize(obj), state, ** end else if pretty ::JSON.pretty_generate normalize(obj), ** else ::JSON.dump normalize(obj), ** end end end |