diff --git a/lib/unit.js b/lib/unit.js index f51eda6cd..45a2dfdf3 100644 --- a/lib/unit.js +++ b/lib/unit.js @@ -187,7 +187,7 @@ Unit.prototype.toObject = function toObject() { }; Unit.prototype.toJSON = function toJSON() { - return this.toObject(); + return JSON.stringify(this.toObject()); }; /** diff --git a/test/unit.js b/test/unit.js index 87fc82fab..063fa6dd9 100644 --- a/test/unit.js +++ b/test/unit.js @@ -124,7 +124,7 @@ describe('Unit', function() { }); it('should input/output JSON', function() { - var json = {amount:1.3, code:'BTC'}; + var json = JSON.stringify({amount:1.3, code:'BTC'}); var unit = Unit.fromJSON(json); unit.toJSON().should.deep.equal(json); });