com.anaptecs.spring.base.serializers.DoubleCodeSerializer Maven / Gradle / Ivy
/*
* anaptecs GmbH, Ricarda-Huch-Str. 71, 72760 Reutlingen, Germany
*
* Copyright 2004 - 2019. All rights reserved.
*/
package com.anaptecs.spring.base.serializers;
import java.io.IOException;
import com.anaptecs.spring.base.DoubleCode;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
/**
* Class implements a JSON / Jackson serializer for class DoubleCode.
*/
public class DoubleCodeSerializer extends JsonSerializer {
@Override
public void serialize( DoubleCode pObject, JsonGenerator pGenerator, SerializerProvider pSerializers )
throws IOException {
// Write value directly to JSON and avoid nesting object structures
pGenerator.writeNumber(pObject.getCode());
}
}