Project

jsonlint

0.06
Low commit activity in last 3 years
There's a lot of open issues
No release in over a year
Checks JSON files for correct syntax and no silly mistakes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2
~> 3.8
~> 13

Runtime

~> 3
 Project Readme

jsonlint

Ruby Gem Version

jsonlint checks your JSON files for syntax errors or silly mistakes. Currently it checks for:

  • Valid JSON syntax
  • Overlapping key definitions in JSON files, where the last definition would win

Installation

Add this line to your application's Gemfile:

gem 'jsonlint'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jsonlint

CLI Usage

You can run jsonlint against a set of files in the command line. Any errors will be printed and the process will exit with a non-zero exit code.

$ jsonlint spec/data/*
spec/data/deep_overlap.json
  The same key is defined twice: foo.bar
spec/data/missing_brace.json
  Hash/Object not terminated at line 5, column 2 [sparse.c:782]
spec/data/missing_comma.json
  expected comma, not a string at line 3, column 8 [sparse.c:386]
spec/data/overlapping_keys.json
  The same key is defined twice: foo

Rake task

You can integrate jsonlint into your build process by adding a Rake task to your project

require 'jsonlint/rake_task'
JsonLint::RakeTask.new do |t|
  t.paths = %w(
    spec/**/*.json
  )
end

Then run the rake task.

$ rake jsonlint
spec/data/deep_overlap.json
  The same key is defined twice: foo.bar
spec/data/missing_brace.json
  Hash/Object not terminated at line 5, column 2 [sparse.c:782]
spec/data/missing_comma.json
  expected comma, not a string at line 3, column 8 [sparse.c:386]
spec/data/overlapping_keys.json
  The same key is defined twice: foo

Rake task options

Add these options similarly to the path option seen above.

Option Description Default
exclude_paths List of files or paths to exclude from linting nil
fail_on_error Continue on to the next rake task when false and don't fail even if JsonLint finds errors true
log_level Logger level (DEBUG, INFO, WARN, ERROR, FATAL, or UNKNOWN) INFO
paths List of files or paths to lint nil

Contributing

  1. Fork it ( https://github.com/dougbarth/jsonlint/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request