当前位置: 首页>>代码示例>>Java>>正文


Java ObjectCodec.treeToValue方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.core.ObjectCodec.treeToValue方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectCodec.treeToValue方法的具体用法?Java ObjectCodec.treeToValue怎么用?Java ObjectCodec.treeToValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.core.ObjectCodec的用法示例。


在下文中一共展示了ObjectCodec.treeToValue方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
/**
 * Deserialize the node field list item.
 * 
 * @param jsonNode
 *            Node which represents the node field list item.
 * @param jsonParser
 * @return Deserialized field list item.
 * @throws JsonProcessingException
 */
public NodeFieldListItem deserialize(JsonNode jsonNode, JsonParser jsonParser) throws JsonProcessingException {
	ObjectCodec oc = jsonParser.getCodec();

	NodeResponse nodeItem = null;
	try {
		// Try to deserialize the node response in the expanded form.
		nodeItem = JsonUtil.readValue(jsonNode.toString(), NodeResponse.class);
	} catch (GenericRestException e) {
		// Fallback and deseralize the element using the collapsed form.
		NodeFieldListItemImpl collapsedItem = oc.treeToValue(jsonNode, NodeFieldListItemImpl.class);
		nodeItem = new NodeResponse();
		nodeItem.setUuid(collapsedItem.getUuid());
	}
	return nodeItem;
}
 
开发者ID:gentics,项目名称:mesh,代码行数:25,代码来源:NodeFieldListItemDeserializer.java

示例2: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public CustomIndicator deserialize(JsonParser p, DeserializationContext ctxt)
		throws IOException, JsonProcessingException {
	List<String> indicatorFields = getDeclaredFields();
	ObjectCodec oc = p.getCodec();
       ObjectNode node = oc.readTree(p);
       CustomIndicator obj = new CustomIndicator(oc.treeToValue(node, Indicator.class));
       Map<String, String> map = new HashMap<String, String>(); 
       //indicator specific fields
       Iterator<String> keys = node.fieldNames();
       while( keys.hasNext() ) {
           String key = (String)keys.next();
           String value = node.get(key).textValue();
           if(!indicatorFields.contains(key)) {
           	map.put(key,  value);
           }
       }
       obj.setMap(map);
       return obj;
       
}
 
开发者ID:ThreatConnect-Inc,项目名称:threatconnect-java,代码行数:22,代码来源:CustomIndicatorDeserializer.java

示例3: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public GenericIndicatorResponseData deserialize(JsonParser p, DeserializationContext ctxt)
		throws IOException, JsonProcessingException {
	GenericIndicatorResponseData result = new GenericIndicatorResponseData();
	ObjectCodec oc = p.getCodec();
	ObjectNode rootNode = oc.readTree(p);
	Iterator<String> keys = rootNode.fieldNames();
	if (keys.hasNext()) {
		String key = (String) keys.next();
		//result.setType(key);
		JsonNode value = rootNode.get(key);
		CustomIndicator obj = oc.treeToValue(value, CustomIndicator.class);
		//obj.setType(key);
		obj.setIndicatorType(key);
		//result.setCustomIndicator(obj);
	}
	return result;

}
 
开发者ID:ThreatConnect-Inc,项目名称:threatconnect-java,代码行数:20,代码来源:GenericIndicatorResponseDataDeserializer.java

示例4: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public CustomIndicatorResponseData deserialize(JsonParser p, DeserializationContext ctxt)
		throws IOException, JsonProcessingException {
	CustomIndicatorResponseData result = new CustomIndicatorResponseData();
	ObjectCodec oc = p.getCodec();
	ObjectNode rootNode = oc.readTree(p);
	Iterator<String> keys = rootNode.fieldNames();
	if (keys.hasNext()) {
		String key = (String) keys.next();
		result.setType(key);
		JsonNode value = rootNode.get(key);
		CustomIndicator obj = oc.treeToValue(value, CustomIndicator.class);
		//obj.setType(key);
		obj.setIndicatorType(key);
		result.setCustomIndicator(obj);
	}
	return result;

}
 
开发者ID:ThreatConnect-Inc,项目名称:threatconnect-java,代码行数:20,代码来源:CustomIndicatorResponseDataDeserializer.java

示例5: doDeserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public FieldTitle doDeserialize(ObjectCodec oc, JsonNode node, JsonParser jp, DeserializationContext ctxt) throws IOException {
    FieldTitle ft = new FieldTitle();

    JsonNode key = node.get("key");
    ft.setKey(key.textValue());

    // Set title
    JsonNode title = node.get("title");
    if(title == null) {
        title = node.get("&title");
    }

    TranslationObject loc = null;
    if(title != null) {
        loc = oc.treeToValue(title, TranslationObject.class);
    }
    ft.setTitle(loc);

    return ft;
}
 
开发者ID:Tietoarkisto,项目名称:metka,代码行数:22,代码来源:FieldTitleDeserializer.java

示例6: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@SuppressWarnings("DuplicateThrows")
@Override
public LogEntry deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException {
    ObjectCodec codec = parser.getCodec();
    JsonNode logEntryNode = codec.readTree(parser);

    long index = logEntryNode.get(LOG_ENTRY_INDEX_FIELD).asLong();
    long term = logEntryNode.get(LOG_ENTRY_TERM_FIELD).asLong();

    String stringType = logEntryNode.get(LOG_ENTRY_TYPE_FIELD).textValue();
    if (stringType.equals(LogEntry.Type.NOOP.name())) {
        return new LogEntry.NoopEntry(index, term);

    } else if (stringType.equals(LogEntry.Type.CLIENT.name())) {
        JsonNode commandNode = logEntryNode.get(CLIENT_ENTRY_COMMAND_FIELD);
        Command command = codec.treeToValue(commandNode, Command.class);
        return new LogEntry.ClientEntry(index, term, command);

    } else if (stringType.equals(LogEntry.Type.CONFIGURATION.name())) {
        return new LogEntry.ConfigurationEntry(index, term, Sets.<String>newHashSet(), Sets.<String>newHashSet());

    } else {
        throw new JsonMappingException("unknown type " + stringType);
    }
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:26,代码来源:RaftRPCLogEntry.java

示例7: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public ExpandableNode deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException {

	ObjectCodec oc = jsonParser.getCodec();
	JsonNode node = oc.readTree(jsonParser);
	// Only the node reference impl version has a project name property.
	if (node.has("projectName")) {
		NodeReference basicReference = oc.treeToValue(node, NodeReference.class);
		return basicReference;
	} else {
		NodeResponse expandedField = JsonUtil.readValue(node.toString(), NodeResponse.class);
		return expandedField;
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:15,代码来源:UserNodeReferenceDeserializer.java

示例8: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public TaggedBucketPoint deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    ObjectCodec objectCodec = jp.getCodec();
    JsonNode node = objectCodec.readTree(jp);

    JsonNode tagsJsonNode = node.get("tags");
    JsonNode minJsonNode = node.get("min");
    JsonNode avgJsonNode = node.get("avg");
    JsonNode medianJsonNode = node.get("median");
    JsonNode maxJsonNode = node.get("max");
    JsonNode sumJsonNode = node.get("sum");
    JsonNode samplesJsonNode = node.get("samples");

    JsonNode percentilesJsonNode = node.get("percentiles");
    List<Percentile> percentiles = new ArrayList<Percentile>();
    if (percentilesJsonNode != null) {
        percentiles = objectCodec.treeToValue(percentilesJsonNode, List.class);
    }

    return new TaggedBucketPoint(tagsJsonNode == null ? new HashMap<String, String>() : objectCodec.treeToValue(tagsJsonNode, Map.class),
                                 minJsonNode == null ? 0 : minJsonNode.asDouble(),
                                 avgJsonNode == null ? 0 : avgJsonNode.asDouble(),
                                 medianJsonNode == null ? 0 : medianJsonNode.asDouble(),
                                 maxJsonNode == null ? 0 : maxJsonNode.asDouble(),
                                 sumJsonNode == null ? 0 : sumJsonNode.asDouble(),
                                 samplesJsonNode == null ? 0 : samplesJsonNode.asInt(),
                                 percentiles);
}
 
开发者ID:hawkular,项目名称:hawkular-client-java,代码行数:30,代码来源:TaggedBucketPointDeserializer.java

示例9: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
public Object deserialize(JsonParser jsonParser, DeserializationContext ctx) throws IOException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  String resultType = node.get("type").asText();
  try {
    Class type = Class.forName(resultType)  ;
    JsonNode rnode = node.get("data") ;
    Object val = oc.treeToValue(rnode, type);
    return val ;
  } catch (ClassNotFoundException e) {
    throw new IOException(e) ;
  }
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:14,代码来源:JSONSerializer.java

示例10: doDeserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
protected Option doDeserialize(ObjectCodec oc, JsonNode node, JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonNode value = node.get("value");
    if(value == null || value.getNodeType() == JsonNodeType.NULL) {
        return null;
    }

    Option o = new Option(value.textValue());

    // Set deprecated
    JsonNode dep = node.get("deprecated");
    if(dep != null && dep.getNodeType() != JsonNodeType.NULL) {
        o.setDeprecated(dep.asBoolean());
    }

    // Set title
    JsonNode title = node.get("title");
    if(title == null) {
        title = node.get("&title");
    }

    TranslationObject loc = null;
    if(title != null) {
        loc = oc.treeToValue(title, TranslationObject.class);
    }
    o.setTitle(loc);

    return o;
}
 
开发者ID:Tietoarkisto,项目名称:metka,代码行数:30,代码来源:OptionDeserializer.java

示例11: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public NumericBucketPoint deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    ObjectCodec objectCodec = jp.getCodec();
    JsonNode node = objectCodec.readTree(jp);

    long start = 0L;
    JsonNode startJsonNode = node.get("start");
    if (startJsonNode != null) {
        start = startJsonNode.asLong();
    }

    long end = 0L;
    JsonNode endJsonNode = node.get("end");
    if (endJsonNode != null) {
        end = endJsonNode.asLong();
    }

    JsonNode minJsonNode = node.get("min");
    JsonNode avgJsonNode = node.get("avg");
    JsonNode medianJsonNode = node.get("median");
    JsonNode maxJsonNode = node.get("max");
    JsonNode sumJsonNode = node.get("sum");
    JsonNode samplesJsonNode = node.get("samples");

    JsonNode percentilesJsonNode = node.get("percentiles");
    List<Percentile> percentiles = new ArrayList<Percentile>();
    if (percentilesJsonNode != null) {
        percentiles = objectCodec.treeToValue(percentilesJsonNode, List.class);
    }

    return new NumericBucketPoint.Builder(start, end)
        .setMin(minJsonNode == null ? 0 : minJsonNode.asDouble())
        .setAvg(avgJsonNode == null ? 0 : avgJsonNode.asDouble())
        .setMedian(medianJsonNode == null ? 0 : medianJsonNode.asDouble())
        .setMax(maxJsonNode == null ? 0 : maxJsonNode.asDouble())
        .setSum(sumJsonNode == null ? 0 : sumJsonNode.asDouble())
        .setSamples(samplesJsonNode == null ? 0 : samplesJsonNode.asInt())
        .setPercentiles(percentiles)
        .build();
}
 
开发者ID:hawkular,项目名称:hawkular-client-java,代码行数:42,代码来源:NumericBucketPointDeserializer.java

示例12: doDeserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public Button doDeserialize(ObjectCodec oc, JsonNode node, JsonParser jp, DeserializationContext ctxt) throws IOException {
    Button btn = new Button();

    // Set title
    JsonNode title = node.get("title");
    if(title == null) {
        title = node.get("&title");
    }

    TranslationObject loc = null;
    if(title != null) {
        loc = oc.treeToValue(title, TranslationObject.class);
    }
    btn.setTitle(loc);

    // Set referenceIsHandledByUser
    JsonNode isHandledByUser = node.get("isHandledByUser");
    if(isHandledByUser != null && isHandledByUser.getNodeType() == JsonNodeType.STRING) {
        btn.setIsHandledByUser(isHandledByUser.textValue());
    }

    // Set isHandler
    JsonNode handler = node.get("isHandler");
    if(handler != null && handler.getNodeType() == JsonNodeType.BOOLEAN) {
        btn.setIsHandler(handler.booleanValue());
    }

    // Set hasHandler
    handler = node.get("hasHandler");
    if(handler != null && handler.getNodeType() == JsonNodeType.BOOLEAN) {
        btn.setHasHandler(handler.booleanValue());
    }

    // Set user groups
    JsonNode groups = node.get("permissions");
    if(groups != null && groups.getNodeType() == JsonNodeType.ARRAY) {
        for(JsonNode group : groups) {
            if(group.getNodeType() == JsonNodeType.STRING) {
                btn.getPermissions().add(group.textValue());
            }
        }
    }

    // Set type
    JsonNode type = node.get("type");
    if(type != null && type.getNodeType() == JsonNodeType.STRING) {
        btn.setType(ButtonType.valueOf(type.textValue()));
    }

    // Set states
    JsonNode states = node.get("states");
    if(states != null && states.getNodeType() == JsonNodeType.ARRAY) {
        for(JsonNode state : states) {
            if(state.getNodeType() == JsonNodeType.STRING) {
                btn.getStates().add(VisibilityState.valueOf(state.textValue()));
            }
        }
    }

    JsonNode customHandler = node.get("customHandler");
    if(customHandler != null && customHandler.getNodeType() == JsonNodeType.STRING) {
        btn.setCustomHandler(customHandler.textValue());
    }

    return btn;
}
 
开发者ID:Tietoarkisto,项目名称:metka,代码行数:68,代码来源:ButtonDeserializer.java

示例13: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@SuppressWarnings("DuplicateThrows")
@Override
public CommandSubclass deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException {
    ObjectCodec codec = parser.getCodec();
    return codec.treeToValue(parser.readValueAsTree(), commandSubclassKlass);
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:7,代码来源:RaftRPCCommand.java


注:本文中的com.fasterxml.jackson.core.ObjectCodec.treeToValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。