Class: Cmdlet::Misc::FormatJson

Inherits:
BaseCmdlet show all
Defined in:
lib/cmdlet/misc/format_json.rb

Overview

FormatJson: FormatJson will take an object and write it out as pretty JSON

Instance Method Summary collapse

Methods inherited from BaseCmdlet

#tokenizer

Instance Method Details

#call(value) ⇒ String

Returns value as pretty JSON string.

Parameters:

  • value (Object)
    • object to be converted to JSON string

Returns:

  • (String)

    value as pretty JSON string



11
12
13
14
15
# File 'lib/cmdlet/misc/format_json.rb', line 11

def call(value)
  return '{}' if value.nil?

  JSON.pretty_generate(value)
end