本文整理汇总了Java中com.fasterxml.jackson.databind.node.ObjectNode.replace方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectNode.replace方法的具体用法?Java ObjectNode.replace怎么用?Java ObjectNode.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.node.ObjectNode
的用法示例。
在下文中一共展示了ObjectNode.replace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nullVersionTest
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test(expected = java.lang.RuntimeException.class)
public void nullVersionTest() throws Exception {
final ObjectNode jsonObject = (ObjectNode) JsonUtil.keyShardSetToJson(keyShardSet);
jsonObject.remove(JsonUtil.VERSION_NAME);
jsonObject.replace(JsonUtil.VERSION_NAME, objectMapper.getNodeFactory().nullNode());
JsonUtil.jsonToKeyShardSet(jsonObject);
}
示例2: onEvent
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public void onEvent(SlackMessagePosted slackMessagePosted, SlackSession slackSession) {
try {
SlackChannel channel = slackMessagePosted.getChannel();
if (slackChannels.contains(channel.getName())) {
ObjectNode jsonNodes = mapper.valueToTree(slackMessagePosted);
jsonNodes.replace("channel", mapper.valueToTree(channel));
jsonNodes.replace("sender", mapper.valueToTree(slackMessagePosted.getSender()));
publisher.sendMessgae(mapper.writeValueAsString(jsonNodes));
log.info("Sent message for channel: {} message: {}", channel.getName(), slackMessagePosted.getMessageContent());
} else {
log.info("Ignored message for channel: {} message: {}", channel.getName(), slackMessagePosted.getMessageContent());
}
} catch (JsonProcessingException | JMSException e) {
log.info("unable to parse message:" + slackMessagePosted.getMessageContent());
}
}
示例3: wrongTypeShardCountTest
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test(expected = java.lang.RuntimeException.class)
public void wrongTypeShardCountTest() throws Exception {
final ObjectNode jsonObject = (ObjectNode) JsonUtil.keyShardSetToJson(keyShardSet);
jsonObject.replace(JsonUtil.SHARD_COUNT_NAME, objectMapper.getNodeFactory().nullNode());
JsonUtil.jsonToKeyShardSet(jsonObject);
}
示例4: zeroShardCountTest
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test(expected = java.lang.RuntimeException.class)
public void zeroShardCountTest() throws Exception {
final ObjectNode jsonObject = (ObjectNode) JsonUtil.keyShardSetToJson(keyShardSet);
jsonObject.replace(JsonUtil.SHARD_COUNT_NAME, objectMapper.getNodeFactory().numberNode(0));
JsonUtil.jsonToKeyShardSet(jsonObject);
}
示例5: noGroupsTest
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test(expected = java.lang.RuntimeException.class)
public void noGroupsTest() throws Exception {
final ObjectNode jsonObject = (ObjectNode) JsonUtil.keyShardSetToJson(keyShardSet);
jsonObject.replace(JsonUtil.GROUPS_NAME, objectMapper.getNodeFactory().arrayNode());
JsonUtil.jsonToKeyShardSet(jsonObject);
}