Parse objects #7

Merged
merged 1 commit into from Jul 17, 2012
Jump to file or symbol
Failed to load files and symbols.
+11 −2
Split
View
@@ -75,6 +75,8 @@ Parser.prototype.parse = function(str){
var self = this
, plugins = this.plugins;
+ if (typeof str !== 'string') str = JSON.stringify(str);
+
return JSON.parse(str, function(key, val){
var plugin, ret;
if ('' === key) return val;
@@ -85,4 +87,4 @@ Parser.prototype.parse = function(str){
}
return val;
});
-};
+};
View
@@ -70,5 +70,12 @@ describe('Parser', function(){
parser.parse('{ "foo": "bar" }')
.should.eql({ foo: 'hey' });
})
+
+ it('should also parse objects', function(){
+ var parser = new Parser
+ , data = { foo: 'bar' };
+
+ parser.parse(data).should.eql(data);
+ })
})
-})
+})