src/js/serializers/JSONSerializer.js
branchpopcorn-port
changeset 128 f3fec80dd31c
parent 108 62da43e72e30
child 137 ef6c1252c459
equal deleted inserted replaced
127:3ce493c93d6c 128:f3fec80dd31c
     1 
     1 
     2 IriSP.JSONSerializer = function(DataLoader, url) {
     2 IriSP.JSONSerializer = function(DataLoader, url) {
     3   IriSP.Serializer.call(this, DataLoader, url);
     3   IriSP.Serializer.call(this, DataLoader, url);
     4 };
     4 };
     5 
     5 
     6 IriSP.JSONSerializer.prototype = IriSP.Serializer;
     6 IriSP.JSONSerializer.prototype = new IriSP.Serializer();
     7 
     7 
     8 IriSP.JSONSerializer.prototype.serialize = function(data) {
     8 IriSP.JSONSerializer.prototype.serialize = function(data) {
     9   return JSON.stringify(data);
     9   return JSON.stringify(data);
    10 };
    10 };
    11 
    11 
    13   return JSON.parse(data);
    13   return JSON.parse(data);
    14 };
    14 };
    15 
    15 
    16 IriSP.JSONSerializer.prototype.sync = function(callback) {
    16 IriSP.JSONSerializer.prototype.sync = function(callback) {
    17   /* we don't have to do much because jQuery handles json for us */
    17   /* we don't have to do much because jQuery handles json for us */
    18   
    18 
    19   /* a wrapper to get a closure because we lose this in callbacks */
    19   /* a wrapper to get a closure because we lose this in callbacks */
    20   var wrapper = function(obj) {
    20   var wrapper = function(obj) {
    21     return function(data) {    
    21     return function(data) {    
    22       obj._data = data;
    22       obj._data = data;
    23       // sort the data too
    23       // sort the data too