"use strict";

var Serializer = require('./Serializer'),
    inherits = require('inherits');

var JSONSerializer = function () {

};

inherits(JSONSerializer, Serializer);

JSONSerializer.prototype.serialize = function (data) {
    return JSON.stringify(data);
};

JSONSerializer.prototype.deserialize = function (data) {
    try {
        return JSON.parse(data);
    } catch (error) {
        return data;
    }
};

module.exports = JSONSerializer;
"use strict";

var Serializer = require('./Serializer'),
    inherits = require('inherits');

var JSONSerializer = function () {

};

inherits(JSONSerializer, Serializer);

JSONSerializer.prototype.serialize = function (data) {
    return JSON.stringify(data);
};

JSONSerializer.prototype.deserialize = function (data) {
    return JSON.parse(data);
};

module.exports = JSONSerializer;
--- 
+++ 
@@ -14,7 +14,11 @@
 };
 
 JSONSerializer.prototype.deserialize = function (data) {
-    return JSON.parse(data);
+    try {
+        return JSON.parse(data);
+    } catch (error) {
+        return data;
+    }
 };
 
 module.exports = JSONSerializer;
Fix JSON parsing with primitive types
