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


Java DeserializationContext.readValue方法代碼示例

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


在下文中一共展示了DeserializationContext.readValue方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deserialize

import com.fasterxml.jackson.databind.DeserializationContext; //導入方法依賴的package包/類
@Override
public ImmutableTable<?, ?, ?> deserialize(final JsonParser jp, final DeserializationContext ctxt)
    throws IOException {
  final ImmutableTable.Builder<Object, Object, Object> tableBuilder = ImmutableTable.builder();

  final JavaType rowKeyType = javaType.containedTypeOrUnknown(0);
  final JavaType columnKeyType = javaType.containedTypeOrUnknown(1);
  final JavaType valueType = javaType.containedTypeOrUnknown(2);
  final JavaType mapifiedType =
      ctxt.getTypeFactory()
          .constructMapType(
              Map.class,
              rowKeyType,
              ctxt.getTypeFactory().constructMapType(Map.class, columnKeyType, valueType));

  final Map<Object, Map<Object, Object>> rowMap = ctxt.readValue(jp, mapifiedType);

  for (final Map.Entry<Object, Map<Object, Object>> rowEntry : rowMap.entrySet()) {
    final Object rowKey = rowEntry.getKey();
    for (final Map.Entry<Object, Object> cellEntry : rowEntry.getValue().entrySet()) {
      final Object colKey = cellEntry.getKey();
      final Object val = cellEntry.getValue();
      tableBuilder.put(rowKey, colKey, val);
    }
  }
  return tableBuilder.build();
}
 
開發者ID:spotify,項目名稱:bazel-tools,代碼行數:28,代碼來源:TableDeserializer.java

示例2: deserialize

import com.fasterxml.jackson.databind.DeserializationContext; //導入方法依賴的package包/類
@Override
public AddressOverview deserialize(JsonParser parser, DeserializationContext context)	
		throws IOException, JsonProcessingException {
	List<Object> propertyList = context.readValue(parser, context.getTypeFactory()
			.constructCollectionType(ArrayList.class, Object.class));
	return toAddressOverview(propertyList);
}
 
開發者ID:Roxas240,項目名稱:CryptoPayAPI,代碼行數:8,代碼來源:AddressOverviewDeserializer.java

示例3: deserialize

import com.fasterxml.jackson.databind.DeserializationContext; //導入方法依賴的package包/類
@Override
public SimpleReport deserialize(JsonParser parser, DeserializationContext ctx) throws IOException {
  JsonNode node = parser.getCodec().readTree(parser);
  SimpleReport report = new SimpleReport();

  if (node.hasNonNull(SimpleReport.KEY_CONFIG_APP)) {
    final AppConfiguration config =
        ctx.readValue(node.get(SimpleReport.KEY_CONFIG_APP).traverse(parser.getCodec()), AppConfiguration.class);
    report.put(SimpleReport.KEY_CONFIG_APP, config);
  }

  if (node.hasNonNull(SimpleReport.KEY_CONFIG_CONTROLLER)) {
    final Controller controller =
        ctx.readValue(node.get(SimpleReport.KEY_CONFIG_CONTROLLER)
            .traverse(parser.getCodec()), Controller.class);
    report.put(SimpleReport.KEY_CONFIG_CONTROLLER, controller);
  }

  if (node.hasNonNull(SimpleReport.KEY_ATTACKS)) {
    List<HttpFloodAttack> httpAttacks = new ArrayList<>();
    Iterator<JsonNode> iter = node.get(SimpleReport.KEY_ATTACKS).elements();
    while (iter.hasNext()) {
      JsonNode n = iter.next();
      HttpFloodAttack attack = ctx.readValue(n.traverse(parser.getCodec()), HttpFloodAttack.class);
      httpAttacks.add(attack);
    }
    report.put(SimpleReport.KEY_ATTACKS, httpAttacks);
  }

  node.fields().forEachRemaining(f -> {
    if (!f.getKey().equals(SimpleReport.KEY_CONFIG_APP) &&
        !f.getKey().equals(SimpleReport.KEY_CONFIG_CONTROLLER) &&
        !f.getKey().equals(SimpleReport.KEY_ATTACKS)) {
      report.put(f.getKey(), f.getValue().asText());
    }
  });

  return report;
}
 
開發者ID:braineering,項目名稱:ares,代碼行數:40,代碼來源:SimpleReportDeserializer.java

示例4: deserialize

import com.fasterxml.jackson.databind.DeserializationContext; //導入方法依賴的package包/類
@Override
public Object[] deserialize(JsonParser jp, DeserializationContext ctxt)
		throws IOException, JsonProcessingException {
	boolean flag = ctxt instanceof NettoDeserializationContext;
	if (!flag) {
		throw new JsonParseException(jp, "ctxt isn't NettoDeserializationContext!");
	}

	Map<String, String> headers = (Map<String, String>) ((NettoDeserializationContext) ctxt).getNettoHeaders();
	ctxt = ((NettoDeserializationContext) ctxt).getContext();
	String methodKey = headers.get(Constants.SERVICE_HEADER) + "/" + headers.get(Constants.METHOD_HEADER) + "/";

	if (headers.containsKey(Constants.ARGSLEN_HEADER)) {
		methodKey = methodKey + headers.get(Constants.ARGSLEN_HEADER);
	}
	Type[] types = null;
	if (this.serviceMethodParameterTypesCache.containsKey(methodKey)) {
		ServiceMethodDesc desc = this.serviceMethodParameterTypesCache.get(methodKey);
		types = desc.types;
	} else {
		throw new JsonParseException(jp, "so such method:" + methodKey);
	}

	int length = types != null ? types.length : 0;
	int currentIndex = 0;
	Object[] args = new Object[length];

	JsonToken currentToken = null;
	while ((currentToken = jp.nextValue()) != null) {
		switch (currentToken) {
		case START_ARRAY:
			continue;
		case END_ARRAY:
			return args;
		default:
			if (currentIndex < length) {
				args[currentIndex] = ctxt.readValue(jp, mapper.getTypeFactory().constructType(types[currentIndex]));
				currentIndex++;
			}
		}

	}

	return args;
}
 
開發者ID:sylinklee,項目名稱:netto_rpc,代碼行數:46,代碼來源:ArgsDeserializer.java

示例5: deserialize

import com.fasterxml.jackson.databind.DeserializationContext; //導入方法依賴的package包/類
@Override
public AppConfiguration deserialize(JsonParser parser, DeserializationContext ctx) throws IOException {
  AppConfiguration config = new AppConfiguration();
  JsonNode node = parser.getCodec().readTree(parser);

  if (node.hasNonNull("cnfInfo")) {
    final boolean cnfInfo = node.get("cnfInfo").asBoolean();
    config.setCnfInfo(cnfInfo);
  }

  if (node.hasNonNull("tgtInfo")) {
    final boolean tgtInfo = node.get("tgtInfo").asBoolean();
    config.setTgtInfo(tgtInfo);
  }

  if (node.hasNonNull("sysInfo")) {
    final boolean sysInfo = node.get("sysInfo").asBoolean();
    config.setSysInfo(sysInfo);
  }

  if (node.hasNonNull("netInfo")) {
    final boolean netInfo = node.get("netInfo").asBoolean();
    config.setNetInfo(netInfo);
  }

  if (node.hasNonNull("polling")) {
    final Interval polling = Interval.valueOf(node.get("polling").asText());
    config.setPolling(polling);
  }

  if (node.hasNonNull("reconnections")) {
    final Long reconnections = (node.get("reconnections").asLong() >= 0) ?
        node.get("reconnections").asLong()
        :
        Long.MAX_VALUE;
    config.setReconnections(reconnections);
  }

  if (node.hasNonNull("reconnectionWait")) {
    final Interval reconnectionWait = Interval.valueOf(node.get("reconnectionWait").asText());
    config.setReconnectionWait(reconnectionWait);
  }

  if (node.hasNonNull("proxy")) {
    final HttpProxy proxy = HttpProxy.valueOf(node.get("proxy").asText());
    config.setProxy(proxy);
  }

  if (node.hasNonNull("sleep")) {
    final String sleep = node.get("sleep").asText();
    config.setSleep(sleep);
  }

  if (node.hasNonNull("authentication")) {
    Map<String,String> authentication = new HashMap<>();
    node.get("authentication").fields().forEachRemaining(f -> authentication.put(f.getKey(), f.getValue().asText()));
    config.setAuthentication(authentication);
  }

  if (node.hasNonNull("controllers")) {
    List<Controller> controllers = new ArrayList<>();
    Iterator<JsonNode> iter = node.get("controllers").elements();
    while (iter.hasNext()) {
      JsonNode n = iter.next();
      Controller controller = ctx.readValue(n.traverse(parser.getCodec()), Controller.class);
      controllers.add(controller);
    }
    config.setControllers(controllers);
  }

  return config;
}
 
開發者ID:braineering,項目名稱:ares,代碼行數:73,代碼來源:AppConfigurationDeserializer.java


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