| 12345678910111213141516171819202122232425262728 |
- //
- // NSDictionary-Additions.m
- // JasonDevelop
- //
- // Created by Jason Lee on 10/29/14.
- // Copyright (c) jasondevelop. All rights reserved.
- //
- #import "NSDictionary-Additions.h"
- @implementation NSDictionary (Additions)
- -(NSString*) jsonStringWithPrettyPrint:(BOOL) prettyPrint {
- NSError *error;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self
- options:(NSJSONWritingOptions) (prettyPrint ? NSJSONWritingPrettyPrinted : 0)
- error:&error];
- if (!jsonData) {
- NSLog(@"bv_jsonStringWithPrettyPrint: error: %@", error.localizedDescription);
- return @"{}";
- } else {
- return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- }
- }
- @end
|