@Override
    public void serialize(EncryptedValue value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        gen.writeStartObject();

        if (EncryptedValueMapperConfig.isDatabase(provider)) {
            // If we want to store this field into the database, we serialize the actual content
            gen.writeStringField("encrypted_value", value.value());
            gen.writeStringField("salt", value.salt());
        } else {
            // In all other contexts, we just serialize the "is_set" field (e.g. HTTP response)
            gen.writeBooleanField("is_set", value.isSet());
        }

        gen.writeEndObject();
    }
@Test
    void serialize() throws Exception {
        final EncryptedValue value = EncryptedValue.builder()
                .value("2d043f9a7d5a5a7537d3e93c93c5dc40")
                .salt("c93c0263bfc3713d")
                .isDeleteValue(false)
                .isKeepValue(false)
                .build();

        final String jsonString = objectMapper.writeValueAsString(value);

        final JsonNode node = objectMapper.readValue(jsonString, JsonNode.class);

        assertThat(node.path("is_set").isBoolean()).isTrue();
        assertThat(node.path("is_set").asBoolean()).isTrue();
    }