其他分享
首页 > 其他分享> > Long 类型格式化成String 传给前端

Long 类型格式化成String 传给前端

作者:互联网

 

 

/**
     * 订单编码:日期时间毫秒+随机数共19位
     */
    @ApiModelProperty(value = "订单编码:日期时间毫秒+随机数共19位")
    @JsonSerialize(using = JsonLongSerializer.class )
    private Long orderNo;

 

 

 

package com.yq.utils;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @author: wensm
 * @date: 2021/5/13 0013
 * @description: TODO
 **/
public class JsonLongSerializer extends JsonSerializer<Long> {
    @Override
    public void serialize(Long aLong, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeString(Long.toString(aLong));
    }
}

 

标签:JsonLongSerializer,jackson,String,Long,import,com,格式化,fasterxml
来源: https://www.cnblogs.com/mingforyou/p/14786135.html