Module: Fog::JSON

Defined in:
lib/fog/core/json.rb

Class Method Summary collapse

Class Method Details

.decode(obj) ⇒ Object



28
29
30
# File 'lib/fog/core/json.rb', line 28

def self.decode(obj)
  MultiJson.decode(obj)
end

.encode(obj) ⇒ Object

Do the MultiJson introspection at this level so we can define our encode/decode methods and perform the introspection only once rather than once per call.



24
25
26
# File 'lib/fog/core/json.rb', line 24

def self.encode(obj)
  MultiJson.encode(obj)
end

.sanitize(data) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/core/json.rb', line 6

def self.sanitize(data)
  case data
  when Array
    data.map {|datum| sanitize(datum)}
  when Hash
    for key, value in data
      data[key] = sanitize(value)
    end
  when ::Time
    data.strftime("%Y-%m-%dT%H:%M:%SZ")
  else
    data
  end
end