Module: Fog::JSON
- Defined in:
- lib/fog/json.rb
Overview
TODO:
Add require “fog/json” and/or include Fog::JSON+ to providers using its services
Note:
Extracting JSON components out of core is a work in progress.
The JSON module includes functionality that is common between APIs using JSON to send and receive data.
The intent is to provide common code for provider APIs using JSON but not require it for those using XML.
Class Method Summary collapse
- .decode(obj) ⇒ Object
-
.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.
- .sanitize(data) ⇒ Object
Class Method Details
.decode(obj) ⇒ Object
40 41 42 |
# File 'lib/fog/json.rb', line 40 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.
36 37 38 |
# File 'lib/fog/json.rb', line 36 def self.encode(obj) MultiJson.encode(obj) end |
.sanitize(data) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fog/json.rb', line 18 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 |