package com.crm.rely.backend.configuration;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import com.alibaba.fastjson.serializer.SerializeWriter;

import java.lang.reflect.Type;
import java.math.BigDecimal;

public  class BigDecimalSerializer implements ObjectSerializer {

    @Override
    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features){
        SerializeWriter out = serializer.out;
        BigDecimal value = (BigDecimal)object;
        value= value.stripTrailingZeros();
        out.write(value.toPlainString());
    }

}
