geoffyoungs / json-minify-rb Goto Github PK
View Code? Open in Web Editor NEWJSON.minify implementation for Ruby
License: MIT License
JSON.minify implementation for Ruby
License: MIT License
Hi,
Myself, as many others, have been thinking of "why can't we have comments in JSON", because it's really useful sometimes to be able to document the rationale behind things etc.
Anyway, I started thinking about it today again, and I found this gem of yours.
But then, before I tried using it, I tried just adding a comment in my JSON data, and surprisingly, the json
gem accepted it without any complaints whatsoever!
2.4.1 :007 > json_with_comment = <<EOF
2.4.1 :008"> {
2.4.1 :009"> // This is a C++-style comment
2.4.1 :010"> }
2.4.1 :011"> EOF
=> "{\n // This is a C++-style comment\n}\n"
2.4.1 :012 > JSON.parse(json_with_comment)
=> {}
json
gem version 2.1.0 in the test.
I tried uninstalling the gem, and using the built-in JSON parser in Ruby; it also swallowed this input data without further ado.
Is this something that's been added recently? Does it only work with particular versions of the JSON gem? I think it would make sense to try and document some more around this, because many people like me probably just want the data to be "parseable", and it would make sense to let them know that this can be done with the tools they already have, "given that preconditions X, Y and Z are met."
This is really minor, but a friend who's new to Ruby had some issues requiring the gem, b/c he was trying to require 'json_minify', whereas he needed to require 'json/minify'. Would be nice to include that in the example.
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.