Aria Stewart ([info]aredridel) wrote,
@ 2007-08-17 16:16:00
Previous Entry  Add to memories!  Tell a Friend!  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"?



(Post a new comment)

Also
[info]drbrain
2007-08-18 12:45 am UTC (link)
RubyGems dependency stuff exists for a reason people! Use it!

(Reply to this)(Thread)


[info]carissatuxys
2008-07-16 03:59 pm UTC (link)
So together with the removal of rubygems dependency, the new ebuild also has USE flags to enable the figlet, cal, host and fortune plugins.

(Reply to this)(Parent)(Thread)


[info]aredridel
2008-07-17 12:39 am UTC (link)
Pardon?

(Reply to this)(Parent)


[info]halostatue
2007-08-18 03:35 am UTC (link)
Did you know there are now three libraries that use the Color namespace?

(I was involved in the reduction of one of them; I'm not sure that the other is going to go away or not.)

There's color-tools (part of PDF::Writer, gem color-tools), color (the color project), and color (on the butler project). color-tools and the color project are essentially code merged, but there's not been a unified release. I'm hoping that Stefan (from the butler project) will be interested in taking over the whole shebang on the color project and merge his code into the API long-established by color-tools and do more. (If this happens, I would want to take the code that I've merged and release Color 1.4.0 as the successor to Color 0.1.0 and color-tools 1.3.0; we'd release a color-tools 1.4.0 gem that is just a dependency gem to force Color 1.4.0. Then, we can release Color 2.0 which has Stefan's code and perhaps incorporates some stuff from lcms).

Oy.

(Reply to this)


[info]rcoder
2007-08-18 06:42 am UTC (link)
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.

(Reply to this)(Thread)


[info]aredridel
2007-08-18 06:44 am UTC (link)
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)

(Reply to this)(Parent)(Thread)


(Anonymous)
2007-09-08 06:26 am UTC (link)
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)

(Reply to this)(Parent)(Thread)


(Anonymous)
2007-09-08 09:43 am UTC (link)
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..

(Reply to this)(Parent)

json gem offers a StringScanner based implementation
(Anonymous)
2007-09-05 10:25 am UTC (link)
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).

(Reply to this)(Parent)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…