Module: Sfn::Utils::JSON

Included in:
Command::Import, Sfn::Utils, StackExporter
Defined in:
lib/sfn/utils/json.rb

Overview

JSON helper methods

Instance Method Summary collapse

Instance Method Details

#_format_json(thing) ⇒ String

Format object into pretty JSON

Parameters:

  • thing (Object)

Returns:

  • (String)


29
30
31
32
# File 'lib/sfn/utils/json.rb', line 29

def _format_json(thing)
  thing = _from_json(thing) if thing.is_a?(String)
  MultiJson.dump(thing, :pretty => true)
end

#_from_json(thing) ⇒ Object

Load JSON data

Parameters:

  • thing (String)

Returns:

  • (Object)


21
22
23
# File 'lib/sfn/utils/json.rb', line 21

def _from_json(thing)
  MultiJson.load(thing)
end

#_to_json(thing) ⇒ String

Convert to JSON

Parameters:

  • thing (Object)

Returns:

  • (String)


13
14
15
# File 'lib/sfn/utils/json.rb', line 13

def _to_json(thing)
  MultiJson.dump(thing)
end