//
//  RTJsonTransfer.m
//  rtquiz
//
//  Created by 张培创 on 14-10-17.
//  Copyright (c) 2014年 com.duowan. All rights reserved.
//

#import "RTJsonTransfer.h"

@implementation RTJsonTransfer

+ (NSString *)toString:(id)obj
{
    if (obj == nil) {
        return @"";
    } else {
        if ([obj isKindOfClass:[NSString class]]) {
            return obj;
        } else if ([obj respondsToSelector:@selector(stringValue)]) {
            return [obj stringValue];
        } else {
            return @"";
        }
    }
}

+ (NSArray *)toArray:(id)obj
{
    if (obj == nil) {
        return @[];
    } else {
        if ([obj isKindOfClass:[NSArray class]]) {
            return obj;
        } else {
            return @[];
        }
    }
}

+ (NSDictionary *)toDictionary:(id)obj
{
    if (obj == nil) {
        return @{};
    } else {
        if ([obj isKindOfClass:[NSDictionary class]]) {
            return obj;
        } else {
            return @{};
        }
    }
}

@end
