OK, that was a lot harder than expected, but I have a solution.
The approach I took is to request a custom data type in an ajax request, and then implement my own converter.
First of all, the format that I use for dates in my json now has a date ("yyyy-mm-dd"), the original example would look like this:
{ "columns": [ ["date", "Date"], ["number", "active_users"], ], "rows": [ ["date(2012-09-28)", 120, 98, 60], ["date(2012-09-29)", 127, 107, 63] ] }
Then I register a converter to convert text to a custom data type called json_with_dates. The regular expression is used to find the date format and replace it with operators to create date objects. Then Eval is used to build json.
jQuery.ajaxSetup({ converters: { "text json_with_dates": function( text ) { var with_dates = text.replace(/\"date\(([^)]*)\)\"/g, function(a, date){ var dateParts = date.split("-"); return "new Date(" + dateParts[0] + "," + dateParts[1] + "," + dateParts[2] + ")"; }); var converted = eval("(" + with_dates + ")"); return converted; } } });
Then I make an ajax request for the user data type:
$.ajax({ url: div.data('chart'), dataType: 'json_with_dates', success: function(data_including_dates){ console.log("win!"); } });