Module: Xolo::Core::JSONWrappers

Included in:
BaseClasses::ServerObject, BaseClasses::ServerObject
Defined in:
lib/xolo/core/json_wrappers.rb

Overview

constants and methods for consistent JSON processing on the server

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(extender) ⇒ Object

when this module is extended



19
20
21
# File 'lib/xolo/core/json_wrappers.rb', line 19

def self.extended(extender)
  Xolo.verbose_extend extender, self
end

.included(includer) ⇒ Object

when this module is included



24
25
26
# File 'lib/xolo/core/json_wrappers.rb', line 24

def self.included(includer)
  Xolo.verbose_include includer, self
end

Instance Method Details

#parse_json(str) ⇒ Object

A wrapper for JSON.parse that always uses :symbolize_names and ensures UTF-8 encoding



35
36
37
# File 'lib/xolo/core/json_wrappers.rb', line 35

def parse_json(str)
  JSON.parse str.force_encoding('UTF-8'), symbolize_names: true
end