Permalink
Browse files

Merge branch 'master' of github.com:visionmedia/eson

  • Loading branch information...
2 parents fb34642 + 0bb42bc commit 2b5f99d2601227071d5f947b4051a5d6179dbf0c @tj committed Jul 17, 2012
Showing with 11 additions and 2 deletions.
  1. +3 −1 lib/Parser.js
  2. +8 −1 test/parser.js
View
4 lib/Parser.js
@@ -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
9 test/parser.js
@@ -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);
+ })
})
-})
+})

0 comments on commit 2b5f99d

Please sign in to comment.