/customers/iconara.net/iconara.net/httpd.www/blog/wp-content/plugins/wp-super-cache/wp-cache-phase1.php Iconara » No eval(), no JSON

No eval(), no JSON

Since Macromedia has decided on having a crippled eval-function in their runtime, it’s not possible to use the powerful ideas in JSON fully.

Well, not quite, you can plug in a JSON-parser, but that seems to be a little bit of overkill. The point with JSON, in my opinion is to have the runtime do your parsing.

It’s a bummer, JSON is a really smart thing. Why waste your time parsing XML (and since most of you don’t know how to do it in a safe way, why waste debugging hours) when you can get the datastructure directly? Most XML loaded by a ActionScript-application isn’t more than datastructures coded in XML. XML should be reserved for places where it would actually make a difference, where there’s semantics involved.

And why is it so hard to read arbitrary data? The two options to read data are LoadVars and XML, and neither of them handles other formats very well. Is it so hard to understand how to things properly? Have a DataLoader class, which loads text or binary data, and make two subclasses, VarLoader and XMLLoader, which load variables in LoadVars-style and XML-data in XML-style. Simple, clean, extensible.

Note: I’ve changed my mind, I still prefer JSON to XML, even if it means I have to have a JSON-parser on the client. JSON is still much easier to work with than parsing XML without XPath.

Leave a Reply