json_color

It is a library to colorize JSON.

Gem Version Build Status

Installation

Add this line to your application's Gemfile:

gem 'json_color'

And then execute:

$ bundle

Or install it yourself as:

$ gem install json_color

Usage

require 'json_color'

puts JsonColor.colorize("{\n    \"glossary\": {\n        \"title\": \"example glossary\",\n    \"GlossDiv\": {\n            \"title\": \"S\",\n      \"GlossList\": {\n                \"GlossEntry\": {\n                    \"ID\": \"SGML\",\n          \"SortAs\": \"SGML\",\n          \"GlossTerm\": \"Standard Generalized Markup Language\",\n          \"Acronym\": \"SGML\",\n          \"Abbrev\": \"ISO 8879:1986\",\n          \"GlossDef\": {\n                        \"para\": \"A meta-markup language, used to create markup languages such as DocBook.\",\n            \"GlossSeeAlso\": [\"GML\", \"XML\"]\n                    },\n          \"GlossSee\": \"markup\"\n                }\n            }\n        }\n    }\n}\n")

Screenshot

Default color map

module JsonColor
  DEFAULT_COLOR_MAP = {
    :key    => :intense_blue,
    :string => :green,
    :null   => :intense_black,
  }
  ...
end