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