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


Java JsonFormat類代碼示例

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


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

示例1: dateField

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
@Override
public void dateField(JFieldVar field, JsonNode node) {

    String pattern = null;
    if (node.has("customDatePattern")) {
        pattern = node.get("customDatePattern").asText();
    } else if (node.has("customPattern")) {
        pattern = node.get("customPattern").asText();
    } else if (isNotEmpty(getGenerationConfig().getCustomDatePattern())) {
        pattern = getGenerationConfig().getCustomDatePattern();
    } else if (getGenerationConfig().isFormatDates()) {
        pattern = FormatRule.ISO_8601_DATE_FORMAT;
    }

    if (pattern != null && !field.type().fullName().equals("java.lang.String")) {
        field.annotate(JsonFormat.class).param("shape", JsonFormat.Shape.STRING).param("pattern", pattern);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:Jackson2Annotator.java

示例2: timeField

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
@Override
public void timeField(JFieldVar field, JsonNode node) {

    String pattern = null;
    if (node.has("customTimePattern")) {
        pattern = node.get("customTimePattern").asText();
    } else if (node.has("customPattern")) {
        pattern = node.get("customPattern").asText();
    } else if (isNotEmpty(getGenerationConfig().getCustomTimePattern())) {
        pattern = getGenerationConfig().getCustomTimePattern();
    } else if (getGenerationConfig().isFormatDates()) {
        pattern = FormatRule.ISO_8601_TIME_FORMAT;
    }

    if (pattern != null && !field.type().fullName().equals("java.lang.String")) {
        field.annotate(JsonFormat.class).param("shape", JsonFormat.Shape.STRING).param("pattern", pattern);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:Jackson2Annotator.java

示例3: dateTimeField

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
@Override
public void dateTimeField(JFieldVar field, JsonNode node) {
    String timezone = node.has("customTimezone") ? node.get("customTimezone").asText() : "UTC";

    String pattern = null;
    if (node.has("customDateTimePattern")) {
        pattern = node.get("customDateTimePattern").asText();
    } else if (node.has("customPattern")) {
        pattern = node.get("customPattern").asText();
    } else if (isNotEmpty(getGenerationConfig().getCustomDateTimePattern())) {
        pattern = getGenerationConfig().getCustomDateTimePattern();
    } else if (getGenerationConfig().isFormatDateTimes()) {
        pattern = FormatRule.ISO_8601_DATETIME_FORMAT;
    }

    if (pattern != null && !field.type().fullName().equals("java.lang.String")) {
        field.annotate(JsonFormat.class).param("shape", JsonFormat.Shape.STRING).param("pattern", pattern).param("timezone", timezone);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:Jackson2Annotator.java

示例4: testConfigOverrides

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
@Test
public void testConfigOverrides() throws Exception
{
    ObjectMapper mapper = newMapper();
    mapper.configOverride(LocalDate.class)
        .setFormat(JsonFormat.Value.forPattern("yyyy_MM_dd"));
    LocalDate date = LocalDate.of(2005, Month.NOVEMBER, 5);
    VanillaWrapper input = new VanillaWrapper(date);
    final String EXP_DATE = "\"2005_11_05\"";
    String json = mapper.writeValueAsString(input);
    assertEquals("{\"value\":"+EXP_DATE+"}", json);
    assertEquals(EXP_DATE, mapper.writeValueAsString(date));

    // and read back, too
    VanillaWrapper output = mapper.readValue(json, VanillaWrapper.class);
    assertEquals(input.value, output.value);
    LocalDate date2 = mapper.readValue(EXP_DATE, LocalDate.class);
    assertEquals(date, date2);
}
 
開發者ID:FasterXML,項目名稱:jackson-modules-java8,代碼行數:20,代碼來源:LocalDateSerTest.java

示例5: AggregatedSocialStoreLatestApps

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
public AggregatedSocialStoreLatestApps(@JsonProperty("uid") String cardId,
    @JsonProperty("stores") SocialStoreLatestApps.Stores stores,
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "UTC") @JsonProperty("date") Date date,
    @JsonProperty("apps") List<App> apps, @JsonProperty("ab") Ab ab,
    @JsonProperty("cards_shared") List<MinimalCard> minimalCardList,
    @JsonProperty("sharers") List<UserSharerTimeline> sharers, @JsonProperty("urls") Urls urls) {
  this.cardId = cardId;
  this.ownerStore = stores.getUser();
  this.sharedStore = stores.getCard();
  this.date = date;
  this.apps = apps;
  this.ab = ab;
  this.minimalCardList = minimalCardList;
  this.sharers = sharers;
  this.urls = urls;
}
 
開發者ID:Aptoide,項目名稱:aptoide-client-v8,代碼行數:17,代碼來源:AggregatedSocialStoreLatestApps.java

示例6: SocialRecommendation

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
@JsonCreator public SocialRecommendation(@JsonProperty("uid") String cardId,
    @JsonProperty("apps") List<App> apps, @JsonProperty("ab") Ab ab,
    @JsonProperty("user_sharer") Comment.User userSharer, @JsonProperty("my") My my,
    @JsonProperty("likes") List<UserTimeline> likes,
    @JsonProperty("comments") List<CardComment> comments, @JsonProperty("content") String content,
    @JsonProperty("user") Comment.User user,
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "UTC") @JsonProperty("date") Date date,
    @JsonProperty("stats") SocialCardStats stats, @JsonProperty("store") Store store,
    @JsonProperty("urls") Urls urls) {
  super(likes, comments, my, urls);
  this.ab = ab;
  this.content = content;
  this.date = date;
  this.cardId = cardId;
  this.user = user;
  this.userSharer = userSharer;
  this.stats = stats;
  this.store = store;
  if (!apps.isEmpty()) {
    this.app = apps.get(0);
  } else {
    this.app = null;
  }
}
 
開發者ID:Aptoide,項目名稱:aptoide-client-v8,代碼行數:25,代碼來源:SocialRecommendation.java

示例7: AggregatedSocialVideo

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
@JsonCreator public AggregatedSocialVideo(@JsonProperty("uid") String cardId,
    @JsonProperty("title") String title, @JsonProperty("thumbnail") String thumbnailUrl,
    @JsonProperty("publisher") Publisher publisher, @JsonProperty("url") String url,
    @JsonProperty("store") Store store,
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "UTC") @JsonProperty("date") Date date,
    @JsonProperty("apps") List<App> apps, @JsonProperty("ab") Ab ab,
    @JsonProperty("cards_shared") List<MinimalCard> minimalCardList,
    @JsonProperty("sharers") List<UserSharerTimeline> sharers, @JsonProperty("urls") Urls urls) {
  this.cardId = cardId;
  this.title = title;
  this.thumbnailUrl = thumbnailUrl;
  this.publisher = publisher;
  this.url = url;
  this.store = store;
  this.date = date;
  this.apps = apps;
  this.ab = ab;
  this.minimalCards = minimalCardList;
  this.sharers = sharers;
  this.urls = urls;
}
 
開發者ID:Aptoide,項目名稱:aptoide-client-v8,代碼行數:22,代碼來源:AggregatedSocialVideo.java

示例8: SocialInstall

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
@JsonCreator
public SocialInstall(@JsonProperty("uid") String cardId, @JsonProperty("apps") List<App> apps,
    @JsonProperty("ab") Ab ab, @JsonProperty("user_sharer") Comment.User userSharer,
    @JsonProperty("user") Comment.User user, @JsonProperty("likes") List<UserTimeline> likes,
    @JsonProperty("comments") List<CardComment> comments,
    @JsonProperty("stats") SocialCardStats stats, @JsonProperty("my") My my,
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "UTC") @JsonProperty("date") Date date,
    @JsonProperty("store") Store store, @JsonProperty("urls") Urls urls) {
  super(likes, comments, my, urls);
  this.ab = ab;
  this.date = date;
  this.cardId = cardId;
  this.user = user;
  this.userSharer = userSharer;
  this.stats = stats;
  this.store = store;
  if (!apps.isEmpty()) {
    this.app = apps.get(0);
  } else {
    this.app = null;
  }
}
 
開發者ID:Aptoide,項目名稱:aptoide-client-v8,代碼行數:23,代碼來源:SocialInstall.java

示例9: AggregatedSocialInstall

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
public AggregatedSocialInstall(@JsonProperty("uid") String cardId,
    @JsonProperty("apps") List<App> apps, @JsonProperty("ab") Ab ab,
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "UTC") @JsonProperty("date") Date date,
    @JsonProperty("cards_shared") List<MinimalCard> minimalCardList,
    @JsonProperty("sharers") List<UserSharerTimeline> sharers, @JsonProperty("urls") Urls urls) {

  this.minimalCardList = minimalCardList;
  this.sharers = sharers;
  this.cardId = cardId;
  this.ab = ab;
  this.date = date;
  this.urls = urls;
  if (!apps.isEmpty()) {
    this.app = apps.get(0);
  } else {
    this.app = null;
  }
}
 
開發者ID:Aptoide,項目名稱:aptoide-client-v8,代碼行數:19,代碼來源:AggregatedSocialInstall.java

示例10: SocialStoreLatestApps

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
@JsonCreator public SocialStoreLatestApps(@JsonProperty("uid") String cardId,
    @JsonProperty("stores") Stores stores, @JsonProperty("user") Comment.User user,
    @JsonProperty("stats") SocialCardStats stats, @JsonProperty("likes") List<UserTimeline> likes,
    @JsonProperty("comments") List<CardComment> comments, @JsonProperty("my") My my,
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "UTC") @JsonProperty("date") Date date,
    @JsonProperty("user_sharer") Comment.User userSharer, @JsonProperty("apps") List<App> apps,
    @JsonProperty("ab") Ab ab, @JsonProperty("urls") Urls urls) {
  super(likes, comments, my, urls);
  this.user = user;
  this.date = date;
  this.ownerStore = stores.getUser();
  this.sharedStore = stores.getCard();
  this.cardId = cardId;
  this.userSharer = userSharer;
  this.apps = apps;
  this.ab = ab;
  this.stats = stats;
}
 
開發者ID:Aptoide,項目名稱:aptoide-client-v8,代碼行數:19,代碼來源:SocialStoreLatestApps.java

示例11: AggregatedSocialArticle

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
public AggregatedSocialArticle(@JsonProperty("uid") String cardId,
    @JsonProperty("title") String title, @JsonProperty("thumbnail") String thumbnailUrl,
    @JsonProperty("publisher") Publisher publisher, @JsonProperty("store") Store store,
    @JsonProperty("url") String url,
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "UTC") @JsonProperty("date") Date date,
    @JsonProperty("apps") List<App> apps, @JsonProperty("ab") Ab ab,
    @JsonProperty("cards_shared") List<MinimalCard> minimalCardList,
    @JsonProperty("sharers") List<UserSharerTimeline> sharers, @JsonProperty("urls") Urls urls) {
  this.minimalCardList = minimalCardList;
  this.sharers = sharers;
  this.publisher = publisher;
  this.cardId = cardId;
  this.title = title;
  this.thumbnailUrl = thumbnailUrl;
  this.url = url;
  this.date = date;
  this.apps = apps;
  this.ab = ab;
  this.urls = urls;
}
 
開發者ID:Aptoide,項目名稱:aptoide-client-v8,代碼行數:21,代碼來源:AggregatedSocialArticle.java

示例12: 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

示例13: Tick

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
@JsonCreator
public Tick(@JsonProperty("T") @JsonFormat (shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss[.SSS][Z]", timezone="UTC") ZonedDateTime startTime,
            @JsonProperty("O") double open, @JsonProperty("H") double high, @JsonProperty("L") double low, @JsonProperty("C") double close,
            @JsonProperty("V")double volume, @JsonProperty("BV") double baseVolume){
    this.startTime = startTime;
    this.open = open;
    this.high = high;
    this.low = low;
    this.close = close;
    this.volume = volume;
    this.baseVolume = baseVolume;
}
 
開發者ID:CCob,項目名稱:bittrex4j,代碼行數:13,代碼來源:Tick.java

示例14: ObjectSample

import com.fasterxml.jackson.annotation.JsonFormat; //導入依賴的package包/類
public ObjectSample(
        @JsonProperty("foo") final String foo,
        @JsonProperty("bar") final int bar,
        @JsonProperty("baz") @JsonFormat(pattern = "yyyy-MM-dd") final LocalDate baz,
        @JsonProperty("qux") final List<ObjectSample> qux) {
    this.foo = Objects.requireNonNull(foo);
    this.bar = bar;
    this.baz = Objects.requireNonNull(baz);
    this.qux = Objects.requireNonNull(qux);
}
 
開發者ID:backpaper0,項目名稱:spring-boot-vue-simple-sample,代碼行數:11,代碼來源:JsonSampleController.java

示例15: 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


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