Sha256: c2acbba4dd01a5f7ea0b6c70ef992ac4d797e7d0e77ed9773ed23f6e75271d72

Contents?: true

Size: 460 Bytes

Versions: 11

Compression:

Stored size: 460 Bytes

Contents

# frozen_string_literal: true

module Cmdlet
  # Miscellaneous cmdlets
  module Misc
    # FormatJson: FormatJson will take an object and write it out as pretty JSON
    class FormatJson < Cmdlet::BaseCmdlet
      #
      # @param [Object] value - object to be converted to JSON string
      # @return [String] value as pretty JSON string
      def call(value)
        return '{}' if value.nil?

        JSON.pretty_generate(value)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cmdlet-0.14.0 lib/cmdlet/misc/format_json.rb
cmdlet-0.13.2 lib/cmdlet/misc/format_json.rb
cmdlet-0.13.1 lib/cmdlet/misc/format_json.rb
cmdlet-0.13.0 lib/cmdlet/misc/format_json.rb
cmdlet-0.12.5 lib/cmdlet/misc/format_json.rb
cmdlet-0.12.4 lib/cmdlet/misc/format_json.rb
cmdlet-0.12.3 lib/cmdlet/misc/format_json.rb
cmdlet-0.12.2 lib/cmdlet/misc/format_json.rb
cmdlet-0.12.1 lib/cmdlet/misc/format_json.rb
cmdlet-0.12.0 lib/cmdlet/misc/format_json.rb
cmdlet-0.11.0 lib/cmdlet/misc/format_json.rb