dougbarth / jsonlint Goto Github PK
View Code? Open in Web Editor NEWChecks JSON files for correct syntax and no silly mistakes
License: MIT License
Checks JSON files for correct syntax and no silly mistakes
License: MIT License
When running jsonlint
from the command line, it throws:
[DEPRECATION] This gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
I suppose it means to use https://github.com/ManageIQ/optimist
I tested each of these dependencies and just simply require 'trollop'
gave the deprecation warning.
gem dependency jsonlint
Gem jsonlint-0.2.0
aruba (>= 0, development)
bundler (~> 1.6, development)
oj (~> 2)
rake (>= 0, development)
rspec (>= 0, development)
trollop (~> 2)
I see this is supported in master branch, looking forward to input validation via Linter class for usage outside of CLI.
For now I am installing gem via git ref as a work around. Example
example
a = JsonLint::Linter.new
a.check_stream StringIO.new '{"a"}'
a.errors
=> {""=>["expected colon, not a hash close at line 1, column 5 [parse.c:549]"]}
It would be nice to just pass in my json string (not necessarily of the IO class, just a string), so I do not have to worry about the #read
method - the errors appear to be strangely formatted as well, in this case, blank string is key.
This could be helpful for quick pipelines.
Just cuz.
The constant argument. Tabs vs. spaces vs. both.
Right now the code is doing two passes through the JSON document. First to see if it is parseable and then second to find overlapping keys.
The streaming callback API seems to have enough information to support both checks. This code should be refactored to do all linting in single pass. Perhaps with some sort of streaming event multiplexer so all the logic isn't mixed up together.
Running jsonlint with no args doesn't print any usage output. This should be fixed up.
I am having an issue and I can only reproduce it in my jenkins instance so I assume its something that is related to the system, ruby, and gems installed. Here is the relevant output from my jenkins job with some extra information such as ruby version and gems added for debug purposes.
https://gist.github.com/majormoses/721d610a1a11c0ffde9e1a1aa594cba1
Here is the simple json that was used to test:
https://gist.github.com/majormoses/e3245bf85ec2b1d1248ea2159f6b11f0
Any useful insight as where to look would be greatly appreciated.
The existence of overlapping keys is noted, but it would be nice if snippets from the JSON document were shown to make it obvious where the overlaps are.
When linting an empty file, the tool should throw an error. That is probably a mistake, or some error in a pipeline.
Assuming the JSON is spread across multiple lines, it would be nice to would be nice to highlight when the indentation is inconsistent with the structure of the document.
When the user supplies a filename which is a directory, automatically perform jsonlint'ing of the directory contents, recursively.
Oj's output for parsing errors is kind of sparse. It would be nice to show a snippet of the JSON and point to the exact spot where the error occurred.
Please show basic usage syntax on jsonlint -h
and jsonlint --help
Just being a good Ruby citizen. I'll probably need to switch away from Oj to implement this. https://github.com/dgraham/json-stream might be a good library (pure Ruby).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.