当前位置: 首页>>代码示例>>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;未经允许,请勿转载。