本文整理汇总了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()));
}
示例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());
}
示例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);
}
}
示例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;
}
示例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()));
}
示例6: getSomeLong
import com.fasterxml.jackson.databind.annotation.JsonSerialize; //导入依赖的package包/类
@AdditionalJacksonAnnotation("some_long")
@JsonProperty("some_long_string")
@JsonSerialize(using=ToStringSerializer.class)
Long getSomeLong();
示例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();
示例8: getIgnored
import com.fasterxml.jackson.databind.annotation.JsonSerialize; //导入依赖的package包/类
@JsonSerialize(contentAs = String.class)
public Set<String> getIgnored() {
return ignored;
}
示例9: importTime
import com.fasterxml.jackson.databind.annotation.JsonSerialize; //导入依赖的package包/类
@JsonDeserialize(converter = Time.Nano2Instant.class)
@JsonSerialize(converter = Time.Instant2Nano.class)
Instant importTime();
示例10: lastUsedTime
import com.fasterxml.jackson.databind.annotation.JsonSerialize; //导入依赖的package包/类
@JsonDeserialize(converter = Time.Nano2Instant.class)
@JsonSerialize(converter = Time.Instant2Nano.class)
Instant lastUsedTime();
示例11: createdAt
import com.fasterxml.jackson.databind.annotation.JsonSerialize; //导入依赖的package包/类
@JsonDeserialize(converter = Time.Nano2Instant.class)
@JsonSerialize(converter = Time.Instant2Nano.class)
Instant createdAt();
示例12: startedAt
import com.fasterxml.jackson.databind.annotation.JsonSerialize; //导入依赖的package包/类
@JsonDeserialize(converter = Time.Nano2Instant.class)
@JsonSerialize(converter = Time.Instant2Nano.class)
Instant startedAt();
示例13: getTimeZone
import com.fasterxml.jackson.databind.annotation.JsonSerialize; //导入依赖的package包/类
@JsonSerialize(using = ToStringSerializer.class)
public ZoneId getTimeZone() {
return timeZone;
}
示例14: getLocale
import com.fasterxml.jackson.databind.annotation.JsonSerialize; //导入依赖的package包/类
@JsonSerialize(using = ToStringSerializer.class)
public Locale getLocale() {
return locale;
}
示例15: getOrigin
import com.fasterxml.jackson.databind.annotation.JsonSerialize; //导入依赖的package包/类
@JsonSerialize(using = ToStringSerializer.class)
public OffsetDateTime getOrigin() {
return origin;
}