// // NSDictionary+BVJSONString.m // Smash // // Created by Luca Beretta on 24/03/2019. // Copyright © 2019 Luca Beretta. All rights reserved. // #import "NSDictionary+BVJSONString.h" @implementation NSDictionary (BVJSONString) -(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint { NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self options:(NSJSONWritingOptions) (prettyPrint ? NSJSONWritingPrettyPrinted : 0) error:&error]; if (! jsonData) { NSLog(@"%s: error: %@", __func__, error.localizedDescription); return @"{}"; } else { return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; } } @end