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 Also known as: format_json

Format object into pretty JSON

Parameters:

  • thing (Object)

Returns:

  • (String)


33
34
35
36
# File 'lib/sfn/utils/json.rb', line 33

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

#_from_json(thing) ⇒ Object Also known as: load_json

Load JSON data

Parameters:

  • thing (String)

Returns:

  • (Object)


23
24
25
# File 'lib/sfn/utils/json.rb', line 23

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

#_to_json(thing) ⇒ String Also known as: dump_json

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