Jackson的JSON序列化注解

package com.example.springboot.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class User {

    @JsonProperty("username")
    private String phone;

    @JsonIgnore
    private String pwd;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private LocalDateTime createdTime;

}
posted @ 2022-04-27 20:50  xl4ng  阅读(115)  评论(0编辑  收藏  举报