json组注解转化long to string

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

@JsonSerialize(using = ToStringSerializer.class)
    private Long id;

mvc返回json时转化

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
@JSONField(serializeUsing = ToStringSerializer.class)
    private Long id;

JSONArray array = JSONArray.parseArray(JSON.toJSONString(casePcapsRes));

用json工具类时转化

你可能感兴趣的:(json)