http://osteele.com/archives/2006/02/json-for-openlaszlo

On 2007-02-08, at 11:17 EST, Dave Brueck wrote:

Hi all,

I'm writing a SOLO app that needs to pull data dynamically over HTTP. The problem is that the data is from an existing service and is returned in the JSON format and not XML. In my app I'd like to be able to use the normal dataset stuff though (e.g. populate a grid component).

I've looked around and this doesn't appear to be directly supported (but please let me know if I've overlooked something) so one thought I had was to receive the JSON data, eval it to make it a Javascript object, and then have a function that converts it to a form useable as a dataset (e.g. use LzDataElement and related objects).

The data is always coming from a "safe" source and I can use any version of Flash, so it should be ok for me to just eval() the raw JSON to get a Javascript object. I can also target any version of OpenLaszlo (currently using 4.0B1) if that helps.

Has anyone already written code to do this? Is converting a Javascript object as I described the best approach? Is it hideously slow? I've looked at Oliver Steele's nice JSON library, but that seems to deal with getting the data into Javascript object form - I couldn't see how to take the next step and use it as a datasource.

Thanks for any tips or pointers you can give me. I'd be thrilled to learn that I'm overlooking something easy and obvious. :)

-Dave

Reply via email to