本文整理匯總了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);
}