Rails, what were you thinking? You went and wrote your own ridiculous JSON serializer in pure Ruby, when a perfectly good C-extension gem already does the job 20 times faster. What’s worse, you gave your to_json method (which clobbers every innocent object it can get its grubby little hands on) a completely incompatible method signature from the standard gem version. You just can’t mix the two, which is ALL KINDS OF FUN for those of us who need to push more than 10 reqs/sec.

Then there’s awesome behavior like this:

<cr:code lang=“ruby”> puts {:rails => /fail/x}.to_json #=> {“rails” => /fail/x} </cr:code>

That’s not even valid ECMAScript, let alone JSON. It’s a standard for a reason, foo! It’s not like you can opt out, either. You’re stuck with this pathologically malingering monkeypatch any time you require ActiveSupport.

At least they figured it out eventually.

Anonymous
Anonymous on

They did not figure it out completely. It encodes some characters incorrectly:

Loading development environment (Rails 2.3.5)

JSON::dump([“foo\001bar”]) => “[\"foo\001bar\”]“

For reference:

irb(main):001:0> require ‘json’ => true irb(main):002:0> JSON::dump(["foo\001bar”]) => “[\"foo\u0001bar\”]“

Aphyr on

Oh wow. So they actually break the JSON module itself? That’s awesome.

Aphyr

Post a Comment

Comments are moderated. Links have nofollow. Seriously, spammers, give it a rest.

Please avoid writing anything here unless you're a computer. This is also a trap:

Supports Github-flavored Markdown, including [links](http://foo.com/), *emphasis*, _underline_, `code`, and > blockquotes. Use ```clj on its own line to start an (e.g.) Clojure code block, and ``` to end the block.