Log in

No account? Create an account

Previous Entry | Next Entry

Ruby JSON implementations

Okay, folks, we have a problem here. When you distribute an app or library that uses JSON, will you please document which json you mean?

There's JSON and there's ruby-json (and is that related to ruby-json?)

Also, JSON library authors: do you think you could possibly merge all this and solve it? Or at least document your projects as something other than "the json library for ruby"?


( 11 comments — Leave a comment )
Aug. 18th, 2007 12:45 am (UTC)
RubyGems dependency stuff exists for a reason people! Use it!
Jul. 16th, 2008 03:59 pm (UTC)
So together with the removal of rubygems dependency, the new ebuild also has USE flags to enable the figlet, cal, host and fortune plugins.
Jul. 17th, 2008 12:39 am (UTC)
Oct. 9th, 2008 03:39 pm (UTC)
From an Ubuntu point of view a superior package is good, because it gives people a reason why they should use Ubuntu and switch to the package rather than continue to mess around with the source package as they do now.
Oct. 17th, 2008 07:42 am (UTC)
Resources :mr_as*strong* dependency model exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/mra.
Oct. 17th, 2008 06:39 pm (UTC)
Hm? I'm not sure I follow.

Aug. 18th, 2007 06:42 am (UTC)
Even better, the ruby-json gem provides JSON::Lexer, while the json gem provides JSON::Parser.

I suspect that the C extension (a.k.a. the 'json' gem) is probably overkill; if you can't parse JSON syntax efficiently with regexps and StringScanner, you're probably doing something wrong.
Aug. 18th, 2007 06:44 am (UTC)
I'm thinking the same thing. Worse, to try out e (elemental), I have to package the gems in co-installable ways. I only have one at the moment. (I'm not using gems proper still -- RPM's my tool of choice)
Sep. 8th, 2007 06:26 am (UTC)
hey, i found this thread while trying to figure out a good solution to the problem for the elemental json-y database stuff.. i know requiring both gems is annoying, but more annoying is having to_json take a second...

the json gem is _way_ faster. like 25 or 50 times, something in that range

but, it cant handle '"this"', or "\"this\"" in parsing (its happy to serialize it)

the author says that this is what the RFC wants. im not sure who to believe, the clientside script json.js from jquery has no problem parsing this, nor does the ruby-json gem..ive mailed the author and (s)he says that won't be changing.

id just wrap everything in an array, but that changes the semantics of the data stored, _and_ it requires wrapping it in an array forever, from each place its read/written (growing, as i experiment with lua/erlang, and reading the blobs from the browser over HTTP, etc)

im not sure exactly if his interpretation of the RFC is correct or not.
theres something about the first and last char need to be ASCII, so it can tell the encoding, as far as i can tell the quote characters are. so...

im going to try to learn Ragel and fix the gem, but id rather not have to release yet a third gem... so hopefully the author budges, or i figure out something else (or maybe give in and wrap everything in arrays - feel free to do that yourself, mainly you just need to change one or two lines as it is)
Sep. 8th, 2007 09:43 am (UTC)
Douglas Crockford's own 'Reference Implementation' json.js parses the stuff that ruby's json gem refuses to, btw..

fascinatingly, this text from JSON.org:

A JSON decoder MUST accept all well-formed JSON text. A JSON decoder MAY also accept non-JSON text. A JSON encoder MUST only produce well-formed JSON text. This is consistent with Postel's Law: "Be liberal in what you accept, and conservative in what you send.

so, the 'encoder' to_json from the faulty gem is creating text it cannot parse. i'd say it should probably throw an exception on to_json for strings/nums then..

even tho i think the author is an asshat, i went in and wrapped everything with brackets since the confusion of requiring two gems and having to learn ragel is more than i can deal with at the moment..
Sep. 5th, 2007 10:25 am (UTC)
json gem offers a StringScanner based implementation
The json gem offers a StringScanner based implementation, if you just require 'json/pure' instead of require 'json' or use the json_pure gem instead of the json gem (which offers both implementations).
( 11 comments — Leave a comment )