Class: LLM::JSONAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/json_adapter.rb

Overview

The JSONAdapter class defines the interface for JSON parsers that can be used by the library when dealing with JSON. The following parsers are supported:

Examples:

Change parser

LLM.json = LLM::JSONAdapter::Oj

Direct Known Subclasses

JSON, Oj, Yajl

Defined Under Namespace

Classes: JSON, Oj, Yajl

Class Method Summary collapse

Class Method Details

.dumpString

Returns a JSON string representation of the given object

Returns:

  • (String)

    Returns a JSON string representation of the given object

Raises:

  • (NotImplementedError)


18
# File 'lib/llm/json_adapter.rb', line 18

def self.dump(*) = raise NotImplementedError

.loadObject

Returns a Ruby object parsed from the given JSON string

Returns:

  • (Object)

    Returns a Ruby object parsed from the given JSON string

Raises:

  • (NotImplementedError)


23
# File 'lib/llm/json_adapter.rb', line 23

def self.load(*) = raise NotImplementedError

.parser_errorException

Returns the error raised when parsing fails

Returns:

  • (Exception)

    Returns the error raised when parsing fails



28
# File 'lib/llm/json_adapter.rb', line 28

def self.parser_error = [StandardError]