/** * @deprecated Since 2.7 use {@link #getDefaultPropertyInclusion} instead */ @Deprecated public JsonInclude.Include getSerializationInclusion() { JsonInclude.Include incl = getDefaultPropertyInclusion().getValueInclusion(); return (incl == JsonInclude.Include.USE_DEFAULTS) ? JsonInclude.Include.ALWAYS : incl; }
JsonInclude.Include inclusion = inclV.getValueInclusion(); if (inclusion == JsonInclude.Include.USE_DEFAULTS) { // should not occur but... inclusion = JsonInclude.Include.ALWAYS;
/** * @deprecated Since 2.7 use {@link #getDefaultPropertyInclusion} instead */ @Deprecated public JsonInclude.Include getSerializationInclusion() { JsonInclude.Include incl = _serializationInclusion.getValueInclusion(); return (incl == JsonInclude.Include.USE_DEFAULTS) ? JsonInclude.Include.ALWAYS : incl; }
void writeField(JsonGenerator generator, SerializerProvider provider, String name, String value) throws IOException { switch (provider.getConfig().getDefaultPropertyInclusion().getValueInclusion()) { case NON_NULL: case NON_ABSENT: if (value == null) return; break; case NON_EMPTY: if (value == null || value.isEmpty()) return; break; default: case ALWAYS: // Allow. break; } generator.writeStringField(name, value); } }
void writeField(JsonGenerator generator, SerializerProvider provider, String name, String value) throws IOException { switch (provider.getConfig().getDefaultPropertyInclusion().getValueInclusion()) { case NON_NULL: case NON_ABSENT: if (value == null) return; break; case NON_EMPTY: if (value == null || value.isEmpty()) return; break; default: case ALWAYS: // Allow. break; } generator.writeStringField(name, value); } }
@Override public void serialize( Key value, JsonGenerator jgen, SerializerProvider provider ) throws IOException { jgen.writeStartObject(); boolean includeNull = Include.NON_NULL != provider.getConfig().getDefaultPropertyInclusion().getValueInclusion(); if ( value.getParent() != null || includeNull ) { jgen.writeObjectField( RawKeyConstant.PARENT, value.getParent() ); } if ( value.getKind() != null || includeNull ) { jgen.writeStringField( RawKeyConstant.KIND, value.getKind() ); } jgen.writeNumberField( RawKeyConstant.ID, value.getId() ); if ( value.getName() != null || includeNull ) { jgen.writeStringField( RawKeyConstant.NAME, value.getName() ); } jgen.writeEndObject(); }
static boolean mustIncludeNull(SerializationConfig config, Class<? extends Enumerable> enumerableType) { try { // getDefaultPropertyInclusion exists since Jackson 2.7 JsonInclude.Value inclusion = config.getDefaultPropertyInclusion(enumerableType); if (inclusion != null) return !SKIP_NULL_INCLUSIONS.contains(inclusion.getValueInclusion().name()); } catch (LinkageError le) { LOGGER.log(Level.FINEST, "SerializationConfig.getDefaultPropertyInclusion() unavailable. Using Jackson < 2.7?", le); } try { JsonInclude.Include inclusion = config.getSerializationInclusion(); if (inclusion != null) return !SKIP_NULL_INCLUSIONS.contains(inclusion.name()); } catch (LinkageError le) { LOGGER.log(Level.FINEST, "SerializationConfig.getSerializationInclusion() unavailable. Deprecation removed?", le); } return true; }
@Override public void serialize( Ref ref, JsonGenerator jgen, SerializerProvider provider ) throws IOException { jgen.writeStartObject(); boolean includeNull = Include.NON_NULL != provider.getConfig().getDefaultPropertyInclusion().getValueInclusion(); if ( ref.key() != null || includeNull ) { jgen.writeObjectField( RefConstant.KEY, ref.key() ); } if ( ref.getValue() != null || includeNull ) { jgen.writeObjectField( RefConstant.VALUE, ref.getValue() ); } jgen.writeEndObject(); }
protected static boolean _suppressNulls(JsonInclude.Value inclusion) { if (inclusion == null) { return false; } JsonInclude.Include incl = inclusion.getValueInclusion(); return (incl != JsonInclude.Include.ALWAYS) && (incl != JsonInclude.Include.USE_DEFAULTS); }
protected static boolean _suppressNulls(JsonInclude.Value inclusion) { if (inclusion == null) { return false; } JsonInclude.Include incl = inclusion.getValueInclusion(); return (incl != JsonInclude.Include.ALWAYS) && (incl != JsonInclude.Include.USE_DEFAULTS); }
@Override public JsonInclude.Value findPropertyInclusion(Annotated a) { JsonInclude inc = _findAnnotation(a, JsonInclude.class); JsonInclude.Value value = (inc == null) ? JsonInclude.Value.empty() : JsonInclude.Value.from(inc); // only consider deprecated variant if we didn't have non-deprecated one: if (value.getValueInclusion() == JsonInclude.Include.USE_DEFAULTS) { value = _refinePropertyInclusion(a, value); } return value; }
protected static Object _suppressableValue(JsonInclude.Value inclusion) { if (inclusion == null) { return false; } JsonInclude.Include incl = inclusion.getValueInclusion(); if ((incl == JsonInclude.Include.ALWAYS) || (incl == JsonInclude.Include.NON_NULL) || (incl == JsonInclude.Include.USE_DEFAULTS)) { return null; } return MARKER_FOR_EMPTY; }
protected static Object _suppressableValue(JsonInclude.Value inclusion) { if (inclusion == null) { return false; } JsonInclude.Include incl = inclusion.getValueInclusion(); if ((incl == JsonInclude.Include.ALWAYS) || (incl == JsonInclude.Include.NON_NULL) || (incl == JsonInclude.Include.USE_DEFAULTS)) { return null; } return MARKER_FOR_EMPTY; }
@Override public void serialize( Key value, JsonGenerator jgen, SerializerProvider provider ) throws IOException { if ( value != null || Include.NON_NULL != provider.getConfig().getDefaultPropertyInclusion().getValueInclusion() ) { StringWriter writer = new StringWriter(); JsonGenerator jsonGenerator = jgen.getCodec().getFactory().createGenerator( writer ); jgen.getCodec().writeValue( jsonGenerator, value ); jsonGenerator.close(); jgen.writeFieldName( writer.toString() ); } } }
/** * @deprecated Since 2.7 use {@link #getDefaultPropertyInclusion} instead */ @Deprecated public JsonInclude.Include getSerializationInclusion() { JsonInclude.Include incl = getDefaultPropertyInclusion().getValueInclusion(); return (incl == JsonInclude.Include.USE_DEFAULTS) ? JsonInclude.Include.ALWAYS : incl; }
switch (valueIncl.getValueInclusion()) { case USE_DEFAULTS: break; break; default: inclV = inclV.withContentInclusion(valueIncl.getValueInclusion());
public PropertyBuilder(SerializationConfig config, BeanDescription beanDesc) { _config = config; _beanDesc = beanDesc; // 08-Sep-2016, tatu: This gets tricky, with 3 levels of definitions: // (a) global default inclusion // (b) per-type default inclusion (from annotation or config overrides; // config override having precedence) // (c) per-property override (from annotation on specific property or // config overrides per type of property; // annotation having precedence) // // and not only requiring merging, but also considering special handling // for NON_DEFAULT in case of (b) (vs (a) or (c)) JsonInclude.Value inclPerType = JsonInclude.Value.merge( beanDesc.findPropertyInclusion(JsonInclude.Value.empty()), config.getDefaultPropertyInclusion(beanDesc.getBeanClass(), JsonInclude.Value.empty())); _defaultInclusion = JsonInclude.Value.merge(config.getDefaultPropertyInclusion(), inclPerType); _useRealPropertyDefaults = inclPerType.getValueInclusion() == JsonInclude.Include.NON_DEFAULT; _annotationIntrospector = _config.getAnnotationIntrospector(); }
protected static Object _suppressableValue(JsonInclude.Value inclusion) { if (inclusion == null) { return false; } JsonInclude.Include incl = inclusion.getValueInclusion(); if ((incl == JsonInclude.Include.ALWAYS) || (incl == JsonInclude.Include.NON_NULL) || (incl == JsonInclude.Include.USE_DEFAULTS)) { return null; } return MARKER_FOR_EMPTY; }
protected static boolean _suppressNulls(JsonInclude.Value inclusion) { if (inclusion == null) { return false; } JsonInclude.Include incl = inclusion.getValueInclusion(); return (incl != JsonInclude.Include.ALWAYS) && (incl != JsonInclude.Include.USE_DEFAULTS); }
@Override public JsonInclude.Value findPropertyInclusion(Annotated a) { JsonInclude inc = _findAnnotation(a, JsonInclude.class); JsonInclude.Value value = (inc == null) ? JsonInclude.Value.empty() : JsonInclude.Value.from(inc); // only consider deprecated variant if we didn't have non-deprecated one: if (value.getValueInclusion() == JsonInclude.Include.USE_DEFAULTS) { value = _refinePropertyInclusion(a, value); } return value; }