Created
August 21, 2012 18:36
-
-
Save jmoe/3418205 to your computer and use it in GitHub Desktop.
Pretty print JSON from RABL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PrettyJson | |
def self.dump(object) | |
JSON.pretty_generate(object, {:indent => " "}) | |
end | |
end | |
# config/initializers/rabl_init.rb | |
Rabl.configure do |config| | |
# Commented as these are defaults | |
# config.cache_all_output = false | |
# config.cache_sources = Rails.env != 'development' # Defaults to false | |
# config.cache_engine = Rabl::CacheEngine.new # Defaults to Rails cache | |
# config.escape_all_output = false | |
config.json_engine = PrettyJson # Any multi\_json engines | |
# config.msgpack_engine = nil # Defaults to ::MessagePack | |
# config.bson_engine = nil # Defaults to ::BSON | |
# config.plist_engine = nil # Defaults to ::Plist::Emit | |
config.include_json_root = false | |
# config.include_msgpack_root = true | |
# config.include_bson_root = true | |
# config.include_plist_root = true | |
# config.include_xml_root = false | |
# config.include_child_root = true | |
# config.enable_json_callbacks = false | |
# config.xml_options = { :dasherize => true, :skip_types => false } | |
# config.view_paths = [] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment