com.fasterxml.jackson.databind.JsonSerializable Java Examples

The following examples show how to use com.fasterxml.jackson.databind.JsonSerializable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SerializableSerializer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isEmpty(SerializerProvider serializers, JsonSerializable value) {
    if (value instanceof JsonSerializable.Base) {
        return ((JsonSerializable.Base) value).isEmpty(serializers);
    }
    return false;
}
 
Example #2
Source File: RawValue.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException
{
    if (_value instanceof JsonSerializable) {
        ((JsonSerializable) _value).serialize(gen, serializers);
    } else {
        _serialize(gen);
    }
}
 
Example #3
Source File: RawValue.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers,
        TypeSerializer typeSer) throws IOException
{
    if (_value instanceof JsonSerializable) {
        ((JsonSerializable) _value).serializeWithType(gen, serializers, typeSer);
    } else if (_value instanceof SerializableString) {
        /* Since these are not really to be deserialized (with or without type info),
         * just re-route as regular write, which will create one... hopefully it works
         */
        serialize(gen, serializers);
    }
}
 
Example #4
Source File: RawValue.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void serialize(JsonGenerator gen) throws IOException
{
    if (_value instanceof JsonSerializable) {
        // No SerializerProvider passed, must go via generator, callback
        gen.writeObject(_value);
    } else {
        _serialize(gen);
    }
}
 
Example #5
Source File: POJONode.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException
{
    if (_value == null) {
        serializers.defaultSerializeNull(gen);
    } else if (_value instanceof JsonSerializable) {
        ((JsonSerializable) _value).serialize(gen, serializers);
    } else {
        gen.writeObject(_value);
    }
}
 
Example #6
Source File: ResponseViewsTest.java    From Bastion with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void jsonSerializableResponseView() throws Exception {
    ModelResponse<? extends Sushi> response = Bastion.request(FileRequest.post("http://localhost:9876/sushi",
                                                                               "classpath:/json/create_sushi_request.json"))
                                                     .bind(Sushi.class)
                                                     .call()
                                                     .getResponse();
    Optional<JsonSerializable.Base> node = response.getView(JsonSerializable.Base.class);
    assertThat(node).isNotEmpty();
}
 
Example #7
Source File: SerializableSerializer.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void serialize(JsonSerializable value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
    value.serialize(gen, serializers);
}
 
Example #8
Source File: SerializableSerializer.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public final void serializeWithType(JsonSerializable value, JsonGenerator gen, SerializerProvider serializers,
        TypeSerializer typeSer) throws IOException {
    value.serializeWithType(gen, serializers, typeSer);
}
 
Example #9
Source File: RawValue.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public RawValue(JsonSerializable v) {
    _value = v;
}
 
Example #10
Source File: SerializableSerializer.java    From lams with GNU General Public License v2.0 votes vote down vote up
protected SerializableSerializer() { super(JsonSerializable.class); }