package com.yonge.toolset.emoji.serializer;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import com.vdurmont.emoji.EmojiParser;

import java.io.IOException;
import java.lang.reflect.Type;

/**
 * @Author: liweifan
 * @Data: 2022/4/28 14:39
 */
public class EmojiSerializer implements ObjectSerializer {

    @Override
    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        serializer.write(EmojiParser.parseToUnicode(object.toString()));
    }

}
