aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/JSON.js2
-rw-r--r--test/JsonTest.js17
2 files changed, 13 insertions, 6 deletions
diff --git a/src/JSON.js b/src/JSON.js
index 9fb325ef..4b1326b2 100644
--- a/src/JSON.js
+++ b/src/JSON.js
@@ -70,7 +70,7 @@ function toJsonArray(buf, obj, pretty, stack){
var childPretty = pretty ? pretty + " " : false;
var keys = [];
for(var k in obj) {
- if (!obj.hasOwnProperty(k) || k.indexOf('$$') === 0 || obj[k] === _undefined)
+ if (k.indexOf('$') === 0 || obj[k] === _undefined)
continue;
keys.push(k);
}
diff --git a/test/JsonTest.js b/test/JsonTest.js
index f6da26b5..c723121f 100644
--- a/test/JsonTest.js
+++ b/test/JsonTest.js
@@ -74,11 +74,18 @@ JsonTest.prototype.testItShouldPreventRecursion = function () {
assertEquals('{"a":"b","recursion":RECURSION}', angular.toJson(obj));
};
-JsonTest.prototype.testItShouldSerializeOnlyOwnProperties = function() {
- var parent = createScope();
- var child = createScope(parent);
- child.c = 'c';
- expect(angular.toJson(child)).toEqual('{"c":"c"}');
+JsonTest.prototype.testItShouldIgnore$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}');
+};
+
+JsonTest.prototype.testItShouldSerializeInheritedProperties = function() {
+ var scope = createScope({p:'p'});
+ scope.a = 'a';
+ expect(angular.toJson(scope)).toEqual('{"a":"a","p":"p","this":RECURSION}');
};
JsonTest.prototype.testItShouldSerializeSameObjectsMultipleTimes = function () {