Class: Protocol::WebSocket::Coder::JSON
- Inherits:
-
Object
- Object
- Protocol::WebSocket::Coder::JSON
- Defined in:
- lib/protocol/websocket/coder/json.rb
Overview
A JSON coder that uses the standard JSON library.
Constant Summary collapse
- DEFAULT =
The default JSON coder. This coder will symbolize names.
new(symbolize_names: true)
Instance Method Summary collapse
-
#generate(object) ⇒ Object
Generate a JSON buffer from an object.
-
#initialize(**options) ⇒ JSON
constructor
A new instance of JSON.
-
#parse(buffer) ⇒ Object
Parse a JSON buffer into an object.
Constructor Details
#initialize(**options) ⇒ JSON
Returns a new instance of JSON.
13 14 15 |
# File 'lib/protocol/websocket/coder/json.rb', line 13 def initialize(**) @options = end |
Instance Method Details
#generate(object) ⇒ Object
Generate a JSON buffer from an object.
23 24 25 |
# File 'lib/protocol/websocket/coder/json.rb', line 23 def generate(object) ::JSON.generate(object, **@options) end |
#parse(buffer) ⇒ Object
Parse a JSON buffer into an object.
18 19 20 |
# File 'lib/protocol/websocket/coder/json.rb', line 18 def parse(buffer) ::JSON.parse(buffer, **@options) end |