Skip to content

Commit fe8353b

Browse files
Vojta JinaIgorMinar
authored andcommitted
Changed toJson() to not ignore $ properties
1 parent c780030 commit fe8353b

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

src/JSON.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function toJsonArray(buf, obj, pretty, stack){
7272
var childPretty = pretty ? pretty + " " : false;
7373
var keys = [];
7474
for(var k in obj) {
75-
if (k.indexOf('$') === 0 || obj[k] === _undefined)
75+
if (obj[k] === _undefined)
7676
continue;
7777
keys.push(k);
7878
}

test/JsonSpec.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ describe('json', function(){
4949
expect(fromJson("false")).toBeFalsy();
5050
});
5151

52-
it('should ignore $$ properties', function() {
53-
expect(toJson({$$:0})).toEqual("{}");
54-
});
55-
5652
it('should serialize array with empty items', function() {
5753
var a = [];
5854
a[1] = "X";
@@ -77,18 +73,15 @@ describe('json', function(){
7773
expect(angular.toJson(obj)).toEqual('{"a":"b","recursion":RECURSION}');
7874
});
7975

80-
it('should ignore $ properties', function() {
81-
var scope = createScope();
82-
scope.a = 'a';
83-
scope['$b'] = '$b';
84-
scope.c = 'c';
85-
expect(angular.toJson(scope)).toEqual('{"a":"a","c":"c","this":RECURSION}');
76+
it('should serialize $ properties', function() {
77+
var obj = {$a: 'a'}
78+
expect(angular.toJson(obj)).toEqual('{"$a":"a"}');
8679
});
8780

8881
it('should serialize inherited properties', function() {
89-
var scope = createScope({p:'p'});
90-
scope.a = 'a';
91-
expect(angular.toJson(scope)).toEqual('{"a":"a","p":"p","this":RECURSION}');
82+
var obj = inherit({p:'p'});
83+
obj.a = 'a';
84+
expect(angular.toJson(obj)).toEqual('{"a":"a","p":"p"}');
9285
});
9386

9487
it('should serialize same objects multiple times', function() {

0 commit comments

Comments
 (0)