diff options
| -rw-r--r-- | src/JSON.js | 2 | ||||
| -rw-r--r-- | test/JsonSpec.js | 19 |
2 files changed, 7 insertions, 14 deletions
diff --git a/src/JSON.js b/src/JSON.js index 0cbe6b2d..9ec95805 100644 --- a/src/JSON.js +++ b/src/JSON.js @@ -72,7 +72,7 @@ function toJsonArray(buf, obj, pretty, stack){ var childPretty = pretty ? pretty + " " : false; var keys = []; for(var k in obj) { - if (k.indexOf('$') === 0 || obj[k] === _undefined) + if (obj[k] === _undefined) continue; keys.push(k); } diff --git a/test/JsonSpec.js b/test/JsonSpec.js index db658517..33aae6ff 100644 --- a/test/JsonSpec.js +++ b/test/JsonSpec.js @@ -49,10 +49,6 @@ describe('json', function(){ expect(fromJson("false")).toBeFalsy(); }); - it('should ignore $$ properties', function() { - expect(toJson({$$:0})).toEqual("{}"); - }); - it('should serialize array with empty items', function() { var a = []; a[1] = "X"; @@ -77,18 +73,15 @@ describe('json', function(){ expect(angular.toJson(obj)).toEqual('{"a":"b","recursion":RECURSION}'); }); - it('should ignore $ properties', function() { - var scope = createScope(); - scope.a = 'a'; - scope['$b'] = '$b'; - scope.c = 'c'; - expect(angular.toJson(scope)).toEqual('{"a":"a","c":"c","this":RECURSION}'); + it('should serialize $ properties', function() { + var obj = {$a: 'a'} + expect(angular.toJson(obj)).toEqual('{"$a":"a"}'); }); it('should serialize inherited properties', function() { - var scope = createScope({p:'p'}); - scope.a = 'a'; - expect(angular.toJson(scope)).toEqual('{"a":"a","p":"p","this":RECURSION}'); + var obj = inherit({p:'p'}); + obj.a = 'a'; + expect(angular.toJson(obj)).toEqual('{"a":"a","p":"p"}'); }); it('should serialize same objects multiple times', function() { |
