From 7e03b255fe56040bb68e94f960dac93ef4f24bd5 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 18 Nov 2009 23:16:15 +0000 Subject: [PATCH] Monotone-Parent: d656a1a3c9e97c1b1a23a7959821aa3c54780d86 Monotone-Revision: 8b5b324a1c2f984ac4755fedfc3bf7a66169a6af Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-18T23:16:15 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++++ SoObjects/SOGo/NSString+Utilities.h | 2 ++ SoObjects/SOGo/NSString+Utilities.m | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1d74e93ed..02be841d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-11-18 Wolfgang Sourdeau + * SoObjects/SOGo/NSString+Utilities.m (-isJSONString): new utility + method that determines whether the current string is a json + document. + * SoObjects/SOGo/NSDictionary+BSJSONAdditions.m (+dictionaryWithJSONString:): this constructor now explicitly returns an NSMutableDictionary to avoid messing with mutable diff --git a/SoObjects/SOGo/NSString+Utilities.h b/SoObjects/SOGo/NSString+Utilities.h index 1b29c1df2..7b5b9d5ff 100644 --- a/SoObjects/SOGo/NSString+Utilities.h +++ b/SoObjects/SOGo/NSString+Utilities.h @@ -65,6 +65,8 @@ // LDIF - (BOOL) _isLDIFSafe; +- (BOOL) isJSONString; + @end #endif /* NSSTRING_URL_H */ diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index 792ea6a0b..2c032cba8 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -30,6 +30,7 @@ #import #import "NSArray+Utilities.h" +#import "NSDictionary+BSJSONAdditions.h" #import "NSDictionary+URL.h" #import "NSString+Utilities.h" @@ -422,4 +423,14 @@ static NSMutableCharacterSet *safeLDIFStartChars = nil; return rc; } +- (BOOL) isJSONString +{ + NSDictionary *jsonData; + +#warning this method is a quick and dirty way of detecting the file-format + jsonData = [NSDictionary dictionaryWithJSONString: self]; + + return (jsonData != nil); +} + @end