I'm just trying out ColdBox with jQuery/Microft template plugin. I'm
using ColdBox's renderData method to return a JSON representation of a
query, and the result looks something like this:
{"recordcount":3,"columnlist":"messageid,messagetext,dateposted,firstname,lastname","data":{"messageid":[3,2,1],"messagetext":["hello?
is this thing on???","what? why?","Hello, and
welcome!"],"dateposted":["{ts '2010-12-05 11:32:51'}","{ts '2010-12-05
11:32:17'}","{ts '2010-12-05
09:44:30'}"],"firstname":["Mortimer","Tom","Waldo"],"lastname":["Who","Dickenharry","Emerson"]}}
that makes sense but, I'm having trouble on the client side using that
with the template plugin. It expects an array of individual objects,
each with a field for each query column. The ColdBox JSON response is
an object containing recordcount, columnlist, and data members, where
the data piece is an object keyed by column name, whose values are
arrays with the data for each record. It's equivalent, and more
concise, but not the same.
So:
- Is there a way to tell ColdBox to serialize this as an array of
objects, rather than this format? Yes I know I could write it myself,
just wondering if I'm missing something obvious that's already done.
- Better yet, is there a way for jQuery to convert this json format to
the array of objects the template plugin is looking for, or make use
of it in its current format?
Thanks,
Dave