//
//  ParseHelper.m
//  MCPlus
//
//  Created by KangSH on 2016. 12. 12..
//  Copyright © 2016년 KangSH. All rights reserved.
//

#import "ParseHelper.h"

@implementation ParseHelper

-(NSData *) parseDictionaryToData:(NSDictionary *)dicData{
    
    if (dicData == nil) {
        return nil;
    }
    
    NSError *error;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dicData options:NSJSONWritingPrettyPrinted error:&error];
    
    if (jsonData == nil || error != nil) {
        NSLog(@"%@ Json Encoding Error! : %@", NSStringFromClass([self class]), error.localizedDescription);
    }
    
    return jsonData;
}

-(NSDictionary *) parseDataToDictionary:(NSData *)data {
    
    if (data == nil) {
        return nil;
    }
    
    NSError *error;
    NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
    
    NSLog(@"Data : %@", dic);
    
    return dic;
}

@end
