mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-11 03:15:10 +00:00
merge of '8284970df75a548f065196f3da7fcd70bc8c47b3'
and '8b5b324a1c2f984ac4755fedfc3bf7a66169a6af' Monotone-Parent: 8284970df75a548f065196f3da7fcd70bc8c47b3 Monotone-Parent: 8b5b324a1c2f984ac4755fedfc3bf7a66169a6af Monotone-Revision: 42650c7e11b236bf9b1b25f7089b591ad1af31aa Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-19T14:44:54 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -28,7 +28,7 @@ extern const int jsonDoNotIndent;
|
||||
|
||||
@interface NSDictionary (BSJSONAdditions)
|
||||
|
||||
+ (NSDictionary *)dictionaryWithJSONString:(NSString *)jsonString;
|
||||
+ (NSMutableDictionary *)dictionaryWithJSONString:(NSString *)jsonString;
|
||||
- (NSString *)jsonStringValue;
|
||||
|
||||
@end
|
||||
|
||||
@@ -35,10 +35,10 @@ const int jsonDoNotIndent = -1;
|
||||
|
||||
@implementation NSDictionary (BSJSONAdditions)
|
||||
|
||||
+ (NSDictionary *)dictionaryWithJSONString:(NSString *)jsonString
|
||||
+ (NSMutableDictionary *)dictionaryWithJSONString:(NSString *)jsonString
|
||||
{
|
||||
NSScanner *scanner = [[NSScanner alloc] initWithString:jsonString];
|
||||
NSDictionary *dictionary = nil;
|
||||
NSMutableDictionary *dictionary = nil;
|
||||
[scanner scanJSONObject:&dictionary];
|
||||
[scanner release];
|
||||
return dictionary;
|
||||
|
||||
@@ -45,7 +45,7 @@ extern NSString *jsonNullString;
|
||||
|
||||
@interface NSScanner (PrivateBSJSONAdditions)
|
||||
|
||||
- (BOOL)scanJSONObject:(NSDictionary **)dictionary;
|
||||
- (BOOL)scanJSONObject:(NSMutableDictionary **)dictionary;
|
||||
- (BOOL)scanJSONArray:(NSArray **)array;
|
||||
- (BOOL)scanJSONString:(NSString **)string;
|
||||
- (BOOL)scanJSONValue:(id *)value;
|
||||
|
||||
@@ -48,7 +48,7 @@ NSString *jsonNullString = @"null";
|
||||
|
||||
@implementation NSScanner (PrivateBSJSONAdditions)
|
||||
|
||||
- (BOOL)scanJSONObject:(NSDictionary **)dictionary
|
||||
- (BOOL)scanJSONObject:(NSMutableDictionary **)dictionary
|
||||
{
|
||||
//[self setCharactersToBeSkipped:nil];
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
// LDIF
|
||||
- (BOOL) _isLDIFSafe;
|
||||
|
||||
- (BOOL) isJSONString;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* NSSTRING_URL_H */
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#import <NGExtensions/NGQuotedPrintableCoding.h>
|
||||
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user