mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-21 10:05:34 +08:00
Merge remote branch 'igor/master'
This commit is contained in:
@@ -70,7 +70,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.hasOwnProperty(k) || k.indexOf('$$') === 0 || obj[k] === undefined)
|
||||
continue;
|
||||
keys.push(k);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,13 @@ JsonTest.prototype.testItShouldPreventRecursion = function () {
|
||||
assertEquals('{"a":"b","recursion":RECURSION}', angular.toJson(obj));
|
||||
};
|
||||
|
||||
JsonTest.prototype.testItShouldSerializeOnlyOwnProperties = function() {
|
||||
var parent = { p: 'p'};
|
||||
var child = { c: 'c'};
|
||||
child.__proto__ = parent;
|
||||
assertEquals('{"c":"c"}', angular.toJson(child));
|
||||
}
|
||||
|
||||
JsonTest.prototype.testItShouldSerializeSameObjectsMultipleTimes = function () {
|
||||
var obj = {a:'b'};
|
||||
assertEquals('{"A":{"a":"b"},"B":{"a":"b"}}', angular.toJson({A:obj, B:obj}));
|
||||
|
||||
Reference in New Issue
Block a user