Converting Resultset into JSON

LabKey Support Forum (Inactive)
Converting Resultset into JSON bront  2014-11-13 09:46
Status: Closed
 
hi,

I am working on an APIAction that implements a SQLFragment, (one where I can use User.getUserId() to restrict access to data).

I execute the fragment via SqlSelector, and I am getting data (even iterating the results to get a JSONObject).

It is not, however, I fear the JSONObject that my ExtJS code is quite expecting.

How can I make the leap from a ResultSet to a JSONObject that can populate an ExtJS store?

Many thanks,

bront
 
 
jeckels responded:  2014-11-14 09:48
Hi Bront,

We typically use org.labkey.api.action.ApiQueryResponse, or its more extensive subclass ExtendedApiQueryResponse, to return ResultSets to a client via JSON. It writes out both the metadata about the columns as well as the data rows. It doesn't work with a straight ResultSet though, it works with a QueryView. It may still provide a useful guide.

We have ExtJS store implementations that translate this JSON into a standard Store. As you may know, ExtJS made significant changes to how its Stores work between versions 3 and 4, so there are different implementations in server/api/webapp/clientapi/ext3/data/Store.js and server/api/webapp/clientapi/ext4/data/Store.js.

Thanks,
Josh
 
bront responded:  2014-11-14 10:03
Josh,

Thanks. I appreciate your input. Let me take a look.

cheers,

bront