Created
December 21, 2009 01:27
-
-
Save boucher/260704 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/Foundation/CPDictionary.j b/Foundation/CPDictionary.j | |
| index 52f0765..270a920 100755 | |
| --- a/Foundation/CPDictionary.j | |
| +++ b/Foundation/CPDictionary.j | |
| @@ -148,11 +148,32 @@ | |
| for (var key in object) | |
| { | |
| + if (!object.hasOwnProperty(key)) | |
| + continue; | |
| + | |
| var value = object[key]; | |
| - if (recursively && value.constructor === Object) | |
| - value = [CPDictionary dictionaryWithJSObject:value recursively:YES]; | |
| - | |
| + if (recursively) | |
| + { | |
| + if (value.constructor === Object) | |
| + value = [CPDictionary dictionaryWithJSObject:value recursively:YES]; | |
| + else if ([value isKindOfClass:CPArray]) | |
| + { | |
| + var newValue = []; | |
| + for (var i = 0, count = value.length; i < count; i++) | |
| + { | |
| + var thisValue = value[i]; | |
| + | |
| + if (thisValue.constructor === Object) | |
| + newValue.push([CPDictionary dictionaryWithJSObject:thisValue recursively:YES]); | |
| + else | |
| + newValue.push(thisValue); | |
| + } | |
| + | |
| + value = newValue; | |
| + } | |
| + } | |
| + | |
| [dictionary setObject:value forKey:key]; | |
| } | |
| @@ -609,7 +630,7 @@ | |
| @end | |
| objj_dictionary.prototype.isa = CPDictionary; | |
| -objj_bundle.prototype.toString = function() | |
| +objj_dictionary.prototype.toString = function() | |
| { | |
| return [this description]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment