You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Carl Hall <ca...@gmail.com> on 2009/04/15 18:50:09 UTC

JSON Bundle

I'm just getting into Sling and am starting to port code over that
interacts with JSON.  I found the commons.json bundle but am wondering
why Sling implements these functions itself instead of using something
like json-lib?

Thanks,
Carl

Re: JSON Bundle

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Carl,

Carl Hall schrieb:
> I'm just getting into Sling and am starting to port code over that
> interacts with JSON.  I found the commons.json bundle but am wondering
> why Sling implements these functions itself instead of using something
> like json-lib?

Our commons.json is basically the same as the Java JSON library from
json.org. We added a new JsonWriter and we also "enhanced" the
JsonObject class to ensure property order.

Re property order: We know, that the ECMAScript spec explicitly states,
that properties of an object have no defined order. On the other hand
every browser known on the planet (at least the big ones Firefox and
Internet Explorer) actually have ordered properties: the order is the
order of adding the properties to the object.

We reckon that this has (unfortunately IMHO) become a situation, that
some developers have become to depend on ... So we modified the
JsonObject class. We also tried to convince Douglas Crockford to adapt
his original JsonObject class, but he refused referring to the
ECMAScript spec. So we decided to fork and adapt our own copy.

Hope this helps.

Regards
Felix