» JSON and Cocoon / Reply to comment

Reply to comment


JSON and Cocoon

Posted on 17 November 2005 - 15:49

I'm currently pondering over the (radical) changes that Cocoon needs to stay mainstream in the changing world of web applications frameworks. Among other things, I just had a light bulb moment about JSON.

JSON makes it very easy to send data to an Ajax client. As it's plain JavaScript, just eval() it and you have an object to work with.

Now how does this fit with Cocoon, which is primarily based on XML processing pipelines? Simple: let's write a JSONSerializer, that would basically replace square brackets with curly braces!

But wait, there's more to that: what if the data isn't the result of a pipeline, but just a simple object you already have at hand in your flowscript (Cocoon's controller written in server-side JavaScript)? Simple: just send it back to the client.

Along the existing cocoon.sendPage("mypage"), cocoon.sendPageAndWait("myotherpage") (creates a continuation and suspends the script), let's just add a cocoon.sendObject(myObject)!

This combines the best of both worlds: powerful publication pipelines for complex page layouts, and easy web remoting for applications, by using JavaScript on both the client and server sides.

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options


CAPTCHA
Please answer this question to show that you're not a stupid spam robot.
9 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.