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


Java JsonSerialize類代碼示例

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


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

示例1: annotationStyleJackson1ProducesJackson1Annotations

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void annotationStyleJackson1ProducesJackson1Annotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException {

    Class generatedType = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example",
            config("annotationStyle", "jackson1"))
            .loadClass("com.example.PrimitiveProperties");

    assertThat(schemaRule.getGenerateDir(), not(containsText("com.fasterxml.jackson")));
    assertThat(schemaRule.getGenerateDir(), containsText("org.codehaus.jackson"));

    Method getter = generatedType.getMethod("getA");

    assertThat(generatedType.getAnnotation(org.codehaus.jackson.annotate.JsonPropertyOrder.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(org.codehaus.jackson.map.annotate.JsonSerialize.class), is(notNullValue()));
    assertThat(getter.getAnnotation(org.codehaus.jackson.annotate.JsonProperty.class), is(notNullValue()));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:AnnotationStyleIT.java

示例2: shouldCreateByteArrayFieldWithAnyEncoding

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@Test
public void shouldCreateByteArrayFieldWithAnyEncoding() throws SecurityException, NoSuchFieldException {
    Field field = classWithMediaProperties.getDeclaredField("anyBinaryEncoding");
    JsonSerialize serAnnotation = field.getAnnotation(JsonSerialize.class);
    JsonDeserialize deserAnnotation = field.getAnnotation(JsonDeserialize.class);

    assertThat("any binary encoding field has type byte[]", field.getType(), equalToType(BYTE_ARRAY));
    assertThat("any binary encoding has a serializer", serAnnotation, notNullValue());
    assertThat("any binary encoding has a deserializer", deserAnnotation, notNullValue());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:MediaIT.java

示例3: propertyField

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@Override
public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) {
    if( isQuotedPrintableProperty(propertyNode) ) {
        field.annotate(JsonSerialize.class).param(USING, QuotedPrintableSerializer.class);
        field.annotate(JsonInclude.class).param("value", JsonInclude.Include.NON_NULL);
        field.annotate(JsonDeserialize.class).param(USING, QuotedPrintableDeserializer.class);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:MediaIT.java

示例4: getIncidentsPaged

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@Override
   @JsonSerialize(using = Jackson2HalModule.HalResourcesSerializer.class)
   @JsonDeserialize(using = Jackson2HalModule.HalResourcesDeserializer.class)
public PagedIncidents getIncidentsPaged(int pagenum,int pagesize) {
	LOG.info("Performing get {} web service", applicationProperties.getIncidentApiUrl() +"/incidents");
	final String restUri = applicationProperties.getIncidentApiUrl() +"/incidents?page="+pagenum+"&size="+pagesize;
	ResponseEntity<PagedResources<IncidentBean>> response = restTemplate.exchange(restUri, HttpMethod.GET, null,
			new ParameterizedTypeReference<PagedResources<IncidentBean>>() {});
	//        LOG.info("Total Incidents {}", response.getBody().size());
	PagedResources<IncidentBean> beanResources = response.getBody();
	PagedIncidents incidents = new PagedIncidents(beanResources,pagenum);
	return incidents;
}
 
開發者ID:Azure,項目名稱:CityPower-Build-Sample,代碼行數:14,代碼來源:IncidentServiceImpl.java

示例5: annotationStyleNoneProducesNoAnnotations

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void annotationStyleNoneProducesNoAnnotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException {

    ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example",
            config("annotationStyle", "none"));

    Class generatedType = resultsClassLoader.loadClass("com.example.PrimitiveProperties");

    Method getter = generatedType.getMethod("getA");

    assertThat(generatedType.getAnnotation(JsonPropertyOrder.class), is(nullValue()));
    assertThat(generatedType.getAnnotation(JsonSerialize.class), is(nullValue()));
    assertThat(getter.getAnnotation(JsonProperty.class), is(nullValue()));

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:AnnotationStyleIT.java

示例6: getSomeLong

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@AdditionalJacksonAnnotation("some_long")
@JsonProperty("some_long_string")
@JsonSerialize(using=ToStringSerializer.class)
Long getSomeLong();
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:JacksonMappedWithExtraAnnotation.java

示例7: getIntValue

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@JsonProperty("int_value_property")
@JsonSerialize(converter = IntValueOverrideConverter.StringSerializer.class)
@JsonDeserialize(converter = IntValueOverrideConverter.StringDeserializer.class)
abstract IntValueClass getIntValue();
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:BuilderDeserializationTest.java

示例8: getIgnored

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@JsonSerialize(contentAs = String.class)
public Set<String> getIgnored() {
  return ignored;
}
 
開發者ID:dbmdz,項目名稱:iiif-apis,代碼行數:5,代碼來源:SearchLayer.java

示例9: importTime

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@JsonDeserialize(converter = Time.Nano2Instant.class)
@JsonSerialize(converter = Time.Instant2Nano.class)
Instant importTime();
 
開發者ID:honnix,項目名稱:rkt-launcher,代碼行數:4,代碼來源:Image.java

示例10: lastUsedTime

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@JsonDeserialize(converter = Time.Nano2Instant.class)
@JsonSerialize(converter = Time.Instant2Nano.class)
Instant lastUsedTime();
 
開發者ID:honnix,項目名稱:rkt-launcher,代碼行數:4,代碼來源:Image.java

示例11: createdAt

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@JsonDeserialize(converter = Time.Nano2Instant.class)
@JsonSerialize(converter = Time.Instant2Nano.class)
Instant createdAt();
 
開發者ID:honnix,項目名稱:rkt-launcher,代碼行數:4,代碼來源:App.java

示例12: startedAt

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@JsonDeserialize(converter = Time.Nano2Instant.class)
@JsonSerialize(converter = Time.Instant2Nano.class)
Instant startedAt();
 
開發者ID:honnix,項目名稱:rkt-launcher,代碼行數:4,代碼來源:App.java

示例13: getTimeZone

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@JsonSerialize(using = ToStringSerializer.class)
public ZoneId getTimeZone() {
    return timeZone;
}
 
開發者ID:levin81,項目名稱:daelic,代碼行數:5,代碼來源:TimeFormatExtractionFn.java

示例14: getLocale

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@JsonSerialize(using = ToStringSerializer.class)
public Locale getLocale() {
    return locale;
}
 
開發者ID:levin81,項目名稱:daelic,代碼行數:5,代碼來源:TimeFormatExtractionFn.java

示例15: getOrigin

import com.fasterxml.jackson.databind.annotation.JsonSerialize; //導入依賴的package包/類
@JsonSerialize(using = ToStringSerializer.class)
public OffsetDateTime getOrigin() {
    return origin;
}
 
開發者ID:levin81,項目名稱:daelic,代碼行數:5,代碼來源:PeriodGranularity.java


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