com.fasterxml.jackson.annotation.JsonFormat.Shape#STRING源码实例Demo

下面列出了com.fasterxml.jackson.annotation.JsonFormat.Shape#STRING 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lams   文件: EnumSerializer.java
/**
 * Helper method called to check whether serialization should be done using
 * index (number) or not.
 */
protected static Boolean _isShapeWrittenUsingIndex(Class<?> enumClass,
        JsonFormat.Value format, boolean fromClass,
        Boolean defaultValue)
{
    JsonFormat.Shape shape = (format == null) ? null : format.getShape();
    if (shape == null) {
        return defaultValue;
    }
    // i.e. "default", check dynamically
    if (shape == Shape.ANY || shape == Shape.SCALAR) {
        return defaultValue;
    }
    // 19-May-2016, tatu: also consider "natural" shape
    if (shape == Shape.STRING || shape == Shape.NATURAL) {
        return Boolean.FALSE;
    }
    // 01-Oct-2014, tatu: For convenience, consider "as-array" to also mean 'yes, use index')
    if (shape.isNumeric() || (shape == Shape.ARRAY)) {
        return Boolean.TRUE;
    }
    // 07-Mar-2017, tatu: Also means `OBJECT` not available as property annotation...
    throw new IllegalArgumentException(String.format(
            "Unsupported serialization shape (%s) for Enum %s, not supported as %s annotation",
                shape, enumClass.getName(), (fromClass? "class" : "property")));
}
 
protected boolean useTimestamp(SerializerProvider provider) {
    if (_useTimestamp != null) {
        return _useTimestamp.booleanValue();
    }
    if (_shape != null) {
        if (_shape == Shape.STRING) {
            return false;
        }
        if (_shape == Shape.NUMBER_INT) {
            return true;
        }
    }
    // assume that explicit formatter definition implies use of textual format
    return (_formatter == null) && (provider != null)
            && provider.isEnabled(getTimestampsFeature());
}
 
源代码3 项目: domino-jackson   文件: BaseDateJsonSerializer.java
@Override
protected void doSerialize(JsonWriter writer, Date value, JsonSerializationContext ctx, JsonSerializerParameters params) {
    if ((ctx.isWriteDatesAsTimestamps() || params.getShape().isNumeric()) && params.getShape() != Shape.STRING) {
        writer.value(value.getTime());
    } else {
        String date = JacksonContextProvider.get().dateFormat().format(params, value);
        if (null == params.getPattern()) {
            writer.unescapeValue(date);
        } else {
            writer.value(date);
        }
    }
}
 
源代码4 项目: gwt-jackson   文件: BaseDateJsonSerializer.java
@Override
protected void doSerialize( JsonWriter writer, Date value, JsonSerializationContext ctx, JsonSerializerParameters params ) {
    if ( (ctx.isWriteDatesAsTimestamps() || params.getShape().isNumeric()) && params.getShape() != Shape.STRING ) {
        writer.value( value.getTime() );
    } else {
        String date = DateFormat.format( params, value );
        if ( null == params.getPattern() ) {
            writer.unescapeValue( date );
        } else {
            writer.value( date );
        }
    }
}
 
源代码5 项目: gwt-jackson   文件: JsonFormatTester.java
public FormatDateBean( @JsonProperty( "dateInParameter" ) @JsonFormat( shape = Shape.STRING,
        pattern = "'P'yyyy/MM/dd" ) Date dateParameter ) {
    this.dateInParameter = dateParameter;
}