Protocol::WebSocketSourceProtocolWebSocketCoderJSON

class JSON

A JSON coder that uses the standard JSON library.

Definitions

def initialize(**options)

Initialize a new JSON coder.

Signature

parameter options Hash

Options to pass to the JSON library when parsing or generating.

Implementation

def initialize(**options)
	@options = options
end

def parse(buffer)

Parse a JSON buffer into an object.

Implementation

def parse(buffer)
	::JSON.parse(buffer, **@options)
end

def generate(object)

Generate a JSON buffer from an object.

Implementation

def generate(object)
	::JSON.generate(object, **@options)
end

DEFAULT = new(symbolize_names: true)

The default JSON coder. This coder will symbolize names.