You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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."
The text was updated successfully, but these errors were encountered:
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!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."
The text was updated successfully, but these errors were encountered: