Class: ASIR::Coder::JSON

Inherits:
ASIR::Coder show all
Defined in:
lib/asir/coder/json.rb

Overview

!SLIDE JSON Coder

Note: Symbols are not handled. The actual JSON expression is wrapped with an Array.

Instance Attribute Summary

Attributes included from Log

#_logger

Instance Method Summary collapse

Methods inherited from ASIR::Coder

#_subclass_responsibility, #decode, #encode

Methods included from Log

#_log, #_log_enabled=, #_log_enabled?, #_log_format, #_log_result, enabled, enabled=, included

Methods included from Initialization

#initialize

Instance Method Details

#_decode(obj) ⇒ Object



15
16
17
18
19
# File 'lib/asir/coder/json.rb', line 15

def _decode obj
  parser = ::JSON.parser.new(obj)
  ary = parser.parse
  ary.first
end

#_encode(obj) ⇒ Object



11
12
13
# File 'lib/asir/coder/json.rb', line 11

def _encode obj
  [ obj ].to_json
end