package com.yxcheng.token.common.model;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeFilter;
import com.alibaba.fastjson.serializer.SerializerFeature;

import java.io.Serializable;

public class BaseJsonModel implements Serializable {
    private static final long serialVersionUID = -7532190300864165247L;
    private transient SerializerFeature[] features = new SerializerFeature[3];

    public BaseJsonModel() {
        this.features[0] = SerializerFeature.QuoteFieldNames;
        this.features[1] = SerializerFeature.WriteMapNullValue;
        this.features[2] = SerializerFeature.WriteNullStringAsEmpty;
    }

    public String toString() {
        return JSON.toJSONString(this, this.features);
    }

    public String toString(SerializeFilter... filters) {
        return filters == null ? JSON.toJSONString(this, this.features) : JSON.toJSONString(this, filters, this.features);
    }
}
