I am building a Railo app which deals with a lot of JSON data sent back and forth via Ajax. I've identified an opportunity to optimize its performance, but I'd like to hear some advice from the community before I tackle it.
Here is a good example of the situation.
I have an action on the server that queries a set of bid responses, serializes them to JSON, then returns them to my javascript on the front end, which then parses and renders some HTML. The format in which Railo returns the JSON is the familiar two-node object:
{"COLUMNS":["one","two","three",...],"DATA":["value","value","value",...]}
I wrote a function that utilizes underscore's map() function to convert this format into an array of objects with named nodes:
function toArgsObject(data,columns) {
return _.map(data, function(w){
var q = {};
for (var i=0; i < w.length; i++) { eval("q."+columns[i]+" = w[i]"); };
return q;
});
};
This gets the job done nicely, however the performance isn't very good! Even with swift js interpreters like those in webkit and firefox, this function often accounts for 75% of processing time in the functions that call it, especially when the data sets are large. I'd like to see how much improvement I would get by offloading this processing to the server, but I don't quite have the cfml / cfscript chops to write an efficient version of this.
What I need to come back from the server, then, would look like this:
[
{"one":"value","two":"value","three":"value"},
{"one":"value","two":"value","three":"value"}.
...
]
I understand that the format used by SerializeJSON creates responses that are far smaller and therefore use less bandwidth to send. This is where the experimentation comes in. I'd like to see how it impacts my application to do things differently!
has anyone written a JSON Serializer that can return data in this format?