class Dox::Formatters::Json

Public Instance Methods

format() click to toggle source
# File lib/dox/formatters/json.rb, line 4
def format
  # in cases where the body isn't valid JSON
  # and the headers specify the Content-Type is application/json
  # an error should be raised
  return '' if body.nil? || body.length < 2

  JSON.pretty_generate(JSON.parse(body))
end