New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prettify_json

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettify_json

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

PrettifyJson

prettify_json is a powerful command-line tool designed to enhance the readability of JSON data. Whether you're working with JSON files, strings, or data streamed from the web, prettify_json will format it in a clean, colorful, and human-friendly way.

Features

  • Readability: Formats JSON data for easier reading.
  • Flexibility: Accepts input from files, strings, or standard input.
  • Colorful Output: Adds colors to the JSON keys, strings, numbers, and more for better visual distinction.

Dependencies

  • Ruby (version 2.7.0 or higher)

Installation

Add this line to your application's Gemfile:

gem 'prettify_json'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install prettify_json

Usage

From a File

Prettify JSON data from a file:

$ prettify_json -f path/to/your/file.json

From a String

Prettify JSON data from a string:

$ prettify_json -s '{"key": "value"}'

From Standard Input

Prettify JSON data from standard input:

$ echo '{"key": "value"}' | prettify_json -

From a Web API

Fetch and prettify JSON data from a web API:

$ curl -s https://api.restful-api.dev/objects | prettify_json -

Examples

Example 1: Prettifying a JSON File

$ prettify_json -f sample.json

{
  "name": "John Doe",
  "age": 30,
  "city": "New York"
}

Example 2: Prettifying a JSON String

$ prettify_json -s '{"name": "John Doe", "age": 30, "city": "New York"}'

{
  "name": "John Doe",
  "age": 30,
  "city": "New York"
}

Example 3: Prettifying JSON from a REST API

$ curl -s https://api.restful-api.dev/objects | prettify_json -

[
  {
    "id": 1,
    "name": "Object 1",
    "data": {
      "value": "Sample data"
    }
  },
  {
    "id": 2,
    "name": "Object 2",
    "data": {
      "value": "More sample data"
    }
  }
]

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in lib/prettify_json/version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/talaatmagdyx/prettify_json. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Reporting Bugs / Feature Requests

If you encounter any bugs or have suggestions for new features, please open an issue on GitHub. Your feedback is valuable and helps improve the quality of the gem.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the PrettifyJson project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the code of conduct.


This README provides a comprehensive guide to using your prettify_json gem, with detailed usage examples and instructions for installation, development, and contribution.

FAQs

Package last updated on 25 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc