
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
json_pretty_generate
Advanced tools
Small utility method for pretty generating JSON
Add this line to your application's Gemfile:
gem 'json_pretty_generate'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install json_pretty_generate
There is a single ::call
method.
When the argument is a Hash JSON will be returned with line breaks
obj = { a: 1 }
JSONPrettyGenerate.(obj)
# => "{\n \"a\": 1\n}"
When the argument is JSON it returns JSON with line breaks
obj = "{\"a\":1}"
JSONPrettyGenerate.(obj)
# => "{\n \"a\": 1\n}"
When the argument is a string that is not JSON it returns the argument
obj = "a=1"
JSONPrettyGenerate.(obj)
# => "a=1"
When the argument type is not a String or Hash it will return nil
obj = 1
JSONPrettyGenerate.(obj)
# => nil
You can use a block to filter the obj to a subset of the data. Strings or symbols can be passed to the block argument.
obj = { data: { body: { a: 1 } } }
JSONPrettyGenerate.(obj) { |o| o[:data][:body] }
# => "{\n \"a\": 1\n}"
To run the specs
$ bundle exec rake
Bug reports and pull requests are welcome on GitHub at https://github.com/nikkypx/json_pretty_generate.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that json_pretty_generate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.