Fixed error in function CPDescriptionOfObject when a JSON object property has a null value.

The function can't handle the following JSON object: {name:null}.
Also added a test case for this.
This commit is contained in:
Martin Carlberg
2012-09-14 10:54:41 +02:00
parent a7b40a5cdd
commit 23401d37d8
2 changed files with 12 additions and 0 deletions
+3
View File
@@ -532,6 +532,9 @@ CPLog(@"Got some class: %@", inst);
function CPDescriptionOfObject(anObject)
{
if (!anObject)
return String(anObject);
if (anObject.isa)
{
if ([anObject isKindOfClass:CPString])
+9
View File
@@ -50,6 +50,15 @@
[self assertTrue:expectedReturnValue === returnValue];
}
- (void)testCPDescriptionOfObject
{
var jSON = {"name": "Martin", "access":null},
d = CPDescriptionOfObject(jSON);
[self assertTrue:d.indexOf("name:") !== -1 message:"Can't find 'name:' in description of json " + d];
[self assertTrue:d.indexOf("access:") !== -1 message:"Can't find 'access:' in description of json " + d];
}
@end
@implementation SuperReceiver : CPObject