gson에서 특정 필드 Serialize 제외시키기

CodeDiver·2022년 2월 8일
0

excludeFieldsWithModifiers 설정

private final Gson mGson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.FINAL).create();

변수 선언 시 final 키워드를 추가해서 시리얼라이즈에서 제외시킨다.

public class MeterValuesReq {
    private final Action action = Action.MeterValues; // 직렬화 제외
    private int connectorId;
    private int transactionId;
    private ArrayList<MeterValue> meterValue = new ArrayList<>();
}
profile
Spring Boot, React.JS, Android 개발자

0개의 댓글