|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -27,6 +27,7 @@ import com.fasterxml.jackson.annotation.JsonView; |
|
|
|
import com.fasterxml.jackson.core.JsonEncoding; |
|
|
|
import com.fasterxml.jackson.core.JsonEncoding; |
|
|
|
import com.fasterxml.jackson.core.JsonGenerator; |
|
|
|
import com.fasterxml.jackson.core.JsonGenerator; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectWriter; |
|
|
|
import com.fasterxml.jackson.databind.SerializationFeature; |
|
|
|
import com.fasterxml.jackson.databind.SerializationFeature; |
|
|
|
import com.fasterxml.jackson.databind.ser.FilterProvider; |
|
|
|
import com.fasterxml.jackson.databind.ser.FilterProvider; |
|
|
|
|
|
|
|
|
|
|
|
@ -205,11 +206,11 @@ public abstract class AbstractJackson2View extends AbstractView { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void writeContent(OutputStream stream, Object object) throws IOException { |
|
|
|
protected void writeContent(OutputStream stream, Object object) throws IOException { |
|
|
|
JsonGenerator generator = this.objectMapper.getFactory().createGenerator(stream, this.encoding); |
|
|
|
JsonGenerator generator = this.objectMapper.getFactory().createGenerator(stream, this.encoding); |
|
|
|
|
|
|
|
|
|
|
|
writePrefix(generator, object); |
|
|
|
writePrefix(generator, object); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object value = object; |
|
|
|
Class<?> serializationView = null; |
|
|
|
Class<?> serializationView = null; |
|
|
|
FilterProvider filters = null; |
|
|
|
FilterProvider filters = null; |
|
|
|
Object value = object; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (value instanceof MappingJacksonValue) { |
|
|
|
if (value instanceof MappingJacksonValue) { |
|
|
|
MappingJacksonValue container = (MappingJacksonValue) value; |
|
|
|
MappingJacksonValue container = (MappingJacksonValue) value; |
|
|
|
@ -217,15 +218,14 @@ public abstract class AbstractJackson2View extends AbstractView { |
|
|
|
serializationView = container.getSerializationView(); |
|
|
|
serializationView = container.getSerializationView(); |
|
|
|
filters = container.getFilters(); |
|
|
|
filters = container.getFilters(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (serializationView != null) { |
|
|
|
|
|
|
|
this.objectMapper.writerWithView(serializationView).writeValue(generator, value); |
|
|
|
ObjectWriter objectWriter = (serializationView != null ? |
|
|
|
} |
|
|
|
this.objectMapper.writerWithView(serializationView) : this.objectMapper.writer()); |
|
|
|
else if (filters != null) { |
|
|
|
if (filters != null) { |
|
|
|
this.objectMapper.writer(filters).writeValue(generator, value); |
|
|
|
objectWriter = objectWriter.with(filters); |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
this.objectMapper.writeValue(generator, value); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
objectWriter.writeValue(generator, value); |
|
|
|
|
|
|
|
|
|
|
|
writeSuffix(generator, object); |
|
|
|
writeSuffix(generator, object); |
|
|
|
generator.flush(); |
|
|
|
generator.flush(); |
|
|
|
} |
|
|
|
} |
|
|
|
|