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


Java JsonDeserialize類代碼示例

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


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

示例1: propertyField

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
@Override
public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) {
    field.annotate(JsonProperty.class).param("value", propertyName);
    if (field.type().erasure().equals(field.type().owner().ref(Set.class))) {
        field.annotate(JsonDeserialize.class).param("as", LinkedHashSet.class);
    }

    if (propertyNode.has("javaJsonView")) {
        field.annotate(JsonView.class).param(
                "value", field.type().owner().ref(propertyNode.get("javaJsonView").asText()));
    }

    if (propertyNode.has("description")) {
        field.annotate(JsonPropertyDescription.class).param("value", propertyNode.get("description").asText());
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:Jackson2Annotator.java

示例2: PublicKeyMirrorCredential

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
@JsonCreator
public PublicKeyMirrorCredential(@JsonProperty("hostnamePatterns")
                                 @JsonDeserialize(contentAs = Pattern.class)
                                 Iterable<Pattern> hostnamePatterns,
                                 @JsonProperty("username") String username,
                                 @JsonProperty("publicKey") String publicKey,
                                 @JsonProperty("privateKey") String privateKey,
                                 @JsonProperty("passphrase") String passphrase) {

    super(hostnamePatterns);

    this.username = requireNonEmpty(username, "username");

    requireNonEmpty(publicKey, "publicKey");
    requireNonEmpty(privateKey, "privateKey");
    this.publicKey = requireNonEmpty(publicKey, "publicKey").getBytes(StandardCharsets.UTF_8);
    this.privateKey = requireNonEmpty(privateKey, "privateKey").getBytes(StandardCharsets.UTF_8);

    this.passphrase = decodeBase64OrUtf8(passphrase, "passphrase");
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:21,代碼來源:PublicKeyMirrorCredential.java

示例3: MultipleMirrorConfig

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
@JsonCreator
MultipleMirrorConfig(
        @JsonProperty("enabled") Boolean enabled,
        @JsonProperty("defaultSchedule") String defaultSchedule,
        @JsonProperty(value = "defaultDirection", required = true) MirrorDirection defaultDirection,
        @JsonProperty("defaultLocalPath") String defaultLocalPath,
        @JsonProperty(value = "includes", required = true)
        @JsonDeserialize(contentAs = MirrorInclude.class)
        Iterable<MirrorInclude> includes,
        @JsonProperty("excludes")
        @JsonDeserialize(contentAs = Pattern.class)
        Iterable<Pattern> excludes) {

    super(firstNonNull(enabled, true));
    this.defaultSchedule = cronParser.parse(firstNonNull(defaultSchedule, DEFAULT_SCHEDULE));
    this.defaultDirection = requireNonNull(defaultDirection, "defaultDirection");
    this.defaultLocalPath = firstNonNull(defaultLocalPath, "/");
    this.includes = ImmutableList.copyOf(requireNonNullElements(includes, "includes"));
    if (excludes != null) {
        this.excludes = ImmutableList.copyOf(requireNonNullElements(excludes, "excludes"));
    } else {
        this.excludes = Collections.emptyList();
    }
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:25,代碼來源:DefaultMetaRepository.java

示例4: AddJvmRequest

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
public AddJvmRequest(@JsonProperty(value = "id", required = true)
                     @JsonDeserialize(using = UUIDDeserializer.class)
                     @JsonSerialize(using = UUIDSerializer.class) UUID jvmId,
                     @JsonProperty(value = "an_id", required = true) String analyseId,
                     @JsonProperty(value = "name", required = true) String jvmName,
                     @JsonProperty(value = "vm_ver", required = true) int vmVersion,
                     @JsonProperty(value = "gc_type", required = true) int gcType,
                     @JsonProperty("headers") String headers,
                     @JsonProperty("mem") MemoryStatus memoryStatus) {
    this.jvmId = jvmId;
    this.analyseId = analyseId;
    this.jvmName = jvmName;
    this.vmVersion = vmVersion;
    this.gcType = gcType;
    this.headers = headers;
    this.memoryStatus = memoryStatus;
}
 
開發者ID:dmart28,項目名稱:gcplot,代碼行數:18,代碼來源:AddJvmRequest.java

示例5: jacksonAnnotationAddedWithImplicitName

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
@Test
public void jacksonAnnotationAddedWithImplicitName() throws CannotGenerateCodeException {
  // See also https://github.com/google/FreeBuilder/issues/90
  TypeElement dataType = model.newType(
      "package com.example;",
      "@" + JsonDeserialize.class.getName() + "(builder = DataType.Builder.class)",
      "public interface DataType {",
      "  int getFooBar();",
      "  class Builder extends DataType_Builder {}",
      "}");

  Metadata metadata = analyser.analyse(dataType);

  Property property = getOnlyElement(metadata.getProperties());
  assertPropertyHasJsonPropertyAnnotation(property, "fooBar");
}
 
開發者ID:google,項目名稱:FreeBuilder,代碼行數:17,代碼來源:JacksonSupportTest.java

示例6: jsonAnyGetterAnnotationDisablesImplicitProperty

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
@Test
public void jsonAnyGetterAnnotationDisablesImplicitProperty() throws CannotGenerateCodeException {
  TypeElement dataType = model.newType(
      "package com.example;",
      "@" + JsonDeserialize.class.getName() + "(builder = DataType.Builder.class)",
      "public interface DataType {",
      "  @" + JsonAnyGetter.class.getName(),
      "  " + Map.class.getName() + "<Integer, String> getFooBar();",
      "  class Builder extends DataType_Builder {}",
      "}");

  Metadata metadata = analyser.analyse(dataType);

  Property property = getOnlyElement(metadata.getProperties());
  assertThat(property.getAccessorAnnotations()).named("property accessor annotations").isEmpty();
}
 
開發者ID:google,項目名稱:FreeBuilder,代碼行數:17,代碼來源:JacksonSupportTest.java

示例7: shouldCreateByteArrayFieldWithAnyEncoding

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的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

示例8: propertyField

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的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

示例9: noAnnotationsWorks

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
@SuppressWarnings("deprecation")
@Test
public void noAnnotationsWorks() throws Exception {
  check(ImmutableJacksonMappedWithNoAnnotations.Json.class.getAnnotation(JsonDeserialize.class)).isNull();
  String json = "{\"someString\":\"xxx\"}";
  ImmutableJacksonMappedWithNoAnnotations value =
      OBJECT_MAPPER.readValue(json, ImmutableJacksonMappedWithNoAnnotations.class);
  check(OBJECT_MAPPER.writeValueAsString(value)).is(json);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:ObjectMappedTest.java

示例10: setWithin

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
/**
 * Set the list of containing resources. Must all be instances of {@link SearchLayer}
 *
 * @throws IllegalArgumentException if at least one of the resources is not a {@link SearchLayer}
 */
@JsonDeserialize(contentAs = SearchLayer.class)
@Override
public void setWithin(List<Resource> within) throws IllegalArgumentException {
  if (within.stream().anyMatch(r -> !(r instanceof SearchLayer))) {
    throw new IllegalArgumentException("SearchResult can only be within a SearchLayer.");
  }
  super.setWithin(within);
}
 
開發者ID:dbmdz,項目名稱:iiif-apis,代碼行數:14,代碼來源:SearchResult.java

示例11: PasswordMirrorCredential

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
@JsonCreator
public PasswordMirrorCredential(@JsonProperty("hostnamePatterns")
                                @JsonDeserialize(contentAs = Pattern.class)
                                Iterable<Pattern> hostnamePatterns,
                                @JsonProperty("username") String username,
                                @JsonProperty("password") String password) {
    super(hostnamePatterns);

    this.username = requireNonEmpty(username, "username");
    this.password = requireNonNull(password, "password");
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:12,代碼來源:PasswordMirrorCredential.java

示例12: CreateSessionCommand

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
@JsonCreator
CreateSessionCommand(@JsonProperty("timestamp") @Nullable Long timestamp,
                     @JsonProperty("author") @Nullable Author author,
                     @JsonProperty("session")
                     @JsonDeserialize(using = SimpleSessionJsonDeserializer.class)
                     SimpleSession session) {

    super(CommandType.CREATE_SESSION, timestamp, author);
    this.session = requireNonNull(session, "session");
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:11,代碼來源:CreateSessionCommand.java

示例13: create

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
@JsonCreator
public static Dependencies create(
    @JsonProperty("options") final Options options,
    @JsonDeserialize(using = TableDeserializer.class) @JsonProperty("maven")
        final ImmutableTable<String, String, Maven> maven) {
  return builder().options(options).maven(maven == null ? ImmutableTable.of() : maven).build();
}
 
開發者ID:spotify,項目名稱:bazel-tools,代碼行數:8,代碼來源:Dependencies.java

示例14: getIncidentsPaged

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的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

示例15: Rule

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; //導入依賴的package包/類
@JsonCreator
private Rule(
		@JsonProperty("capabilities") List<Capability> capabilities,
		@JsonProperty("min_wrapping_ttl") @JsonDeserialize(converter = StringToDurationConverter.class) Duration minWrappingTtl,
		@JsonProperty("max_wrapping_ttl") @JsonDeserialize(converter = StringToDurationConverter.class) Duration maxWrappingTtl,
		@JsonProperty("allowed_parameters") Map<String, List<String>> allowedParameters,
		@JsonProperty("denied_parameters") Map<String, List<String>> deniedParameters) {

	this.path = "";
	this.capabilities = capabilities;
	this.minWrappingTtl = minWrappingTtl;
	this.maxWrappingTtl = maxWrappingTtl;
	this.allowedParameters = allowedParameters;
	this.deniedParameters = deniedParameters;
}
 
開發者ID:spring-projects,項目名稱:spring-vault,代碼行數:16,代碼來源:Policy.java


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