package com.sheep.gamegroup.model.util;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sheep.gamegroup.model.entity.Ext;

import org.joda.time.DateTime;

public final class EntityUtils {

    private EntityUtils() {}

    public static final Gson gson = new GsonBuilder()
            .registerTypeAdapter(DateTime.class, new DateTimeTypeAdapter())
            .create();

    public static Ext getExtInfo(String ext){
        Ext extInfo;
        try {
            extInfo = JSONObject.parseObject(ext, Ext.class);
        } catch (Exception e) {
            e.printStackTrace();
            extInfo = JSONObject.parseObject(JSONObject.toJSONString(ext), Ext.class);
        }
        return extInfo;
    }
}
