當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonFormat.Value方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.annotation.JsonFormat.Value方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonFormat.Value方法的具體用法?Java JsonFormat.Value怎麽用?Java JsonFormat.Value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.annotation.JsonFormat的用法示例。


在下文中一共展示了JsonFormat.Value方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createContextual

import com.fasterxml.jackson.annotation.JsonFormat; //導入方法依賴的package包/類
@Override
 public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
         BeanProperty property) throws JsonMappingException
 {
     JsonFormat.Value format = findFormatOverrides(ctxt, property, handledType());
     if (format != null) {
         if (format.hasPattern()) {
             final String pattern = format.getPattern();
             final Locale locale = format.hasLocale() ? format.getLocale() : ctxt.getLocale();
             DateTimeFormatter df;
             if (locale == null) {
                 df = DateTimeFormatter.ofPattern(pattern);
             } else {
                 df = DateTimeFormatter.ofPattern(pattern, locale);
             }
             //Issue #69: For instant serializers/deserializers we need to configure the formatter with
             //a time zone picked up from JsonFormat annotation, otherwise serialization might not work
             if (format.hasTimeZone()) {
                 df = df.withZone(format.getTimeZone().toZoneId());
             }
             return withDateFormat(df);
         }
         // any use for TimeZone?
     }
     return this;
}
 
開發者ID:FasterXML,項目名稱:jackson-modules-java8,代碼行數:27,代碼來源:JSR310DateTimeDeserializerBase.java

示例2: createContextual

import com.fasterxml.jackson.annotation.JsonFormat; //導入方法依賴的package包/類
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
    if (property != null) {
        JsonFormat.Value format = ctxt.getAnnotationIntrospector().findFormat(property.getMember());
        if (format != null && Objects.equals(TransactionSerializer.BASE64_FORMAT, format.getPattern())) {
            return new Base64TransactionDeserializer(formatter);
        }
    }

    return new HexTransactionDeserializer(formatter);
}
 
開發者ID:DigitalAssetCom,項目名稱:-deprecated-hlp-candidate,代碼行數:12,代碼來源:TransactionDeserializer.java

示例3: createContextual

import com.fasterxml.jackson.annotation.JsonFormat; //導入方法依賴的package包/類
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
    if (property != null) {
        JsonFormat.Value format = prov.getAnnotationIntrospector().findFormat(property.getMember());
        if (format != null && Objects.equals(BASE64_FORMAT, format.getPattern())) {
            return new Base64TransactionSerializer();
        }
    }

    return new HexTransactionSerializer();
}
 
開發者ID:DigitalAssetCom,項目名稱:-deprecated-hlp-candidate,代碼行數:12,代碼來源:TransactionSerializer.java

示例4: createContextual

import com.fasterxml.jackson.annotation.JsonFormat; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public JsonDeserializer<T> createContextual(DeserializationContext ctxt,
        BeanProperty property) throws JsonMappingException
{
    InstantDeserializer<T> deserializer =
            (InstantDeserializer<T>)super.createContextual(ctxt, property);
    if (deserializer != this) {
        JsonFormat.Value val = findFormatOverrides(ctxt, property, handledType());
        if (val != null) {
            return  new InstantDeserializer<>(deserializer, val.getFeature(JsonFormat.Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE));
        }
    }
    return this;
}
 
開發者ID:FasterXML,項目名稱:jackson-modules-java8,代碼行數:16,代碼來源:InstantDeserializer.java

示例5: createContextual

import com.fasterxml.jackson.annotation.JsonFormat; //導入方法依賴的package包/類
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov,
        BeanProperty property) throws JsonMappingException
{
    JsonFormat.Value format = findFormatOverrides(prov, property, handledType());
    if (format != null) {
        Boolean useTimestamp = null;

       // Simple case first: serialize as numeric timestamp?
        JsonFormat.Shape shape = format.getShape();
        if (shape == JsonFormat.Shape.ARRAY || shape.isNumeric() ) {
            useTimestamp = Boolean.TRUE;
        } else {
            useTimestamp = (shape == JsonFormat.Shape.STRING) ? Boolean.FALSE : null;
        }
        DateTimeFormatter dtf = _formatter;

        // If not, do we have a pattern?
        if (format.hasPattern()) {
            final String pattern = format.getPattern();
            final Locale locale = format.hasLocale() ? format.getLocale() : prov.getLocale();
            if (locale == null) {
                dtf = DateTimeFormatter.ofPattern(pattern);
            } else {
                dtf = DateTimeFormatter.ofPattern(pattern, locale);
            }
            //Issue #69: For instant serializers/deserializers we need to configure the formatter with
            //a time zone picked up from JsonFormat annotation, otherwise serialization might not work
            if (format.hasTimeZone()) {
                dtf = dtf.withZone(format.getTimeZone().toZoneId());
            }
        }
        JSR310FormattedSerializerBase<?> ser = this;
        if ((shape != _shape) || (useTimestamp != _useTimestamp) || (dtf != _formatter)) {
            ser = ser.withFormat(useTimestamp, dtf, shape);
        }
        Boolean writeZoneId = format.getFeature(JsonFormat.Feature.WRITE_DATES_WITH_ZONE_ID);
        if (writeZoneId != null) {
            ser = ser.withFeatures(writeZoneId);
        }
        return ser;
    }
    return this;
}
 
開發者ID:FasterXML,項目名稱:jackson-modules-java8,代碼行數:45,代碼來源:JSR310FormattedSerializerBase.java


注:本文中的com.fasterxml.jackson.annotation.JsonFormat.Value方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。