本文整理匯總了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;
}