• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MissingNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.fasterxml.jackson.databind.node.MissingNode的典型用法代码示例。如果您正苦于以下问题:Java MissingNode类的具体用法?Java MissingNode怎么用?Java MissingNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MissingNode类属于com.fasterxml.jackson.databind.node包,在下文中一共展示了MissingNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: apply

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
@Override
JsonNode apply(final JsonNode node) {
    if (path.toString().isEmpty()) {
        return MissingNode.getInstance();
    }
    ensureExistence(node);

    final JsonNode parentNode = node.at(path.head());
    final String raw = path.last().getMatchingProperty();
    if (parentNode.isObject()) {
        ((ObjectNode) parentNode).remove(raw);
    } else {
        ((ArrayNode) parentNode).remove(Integer.parseInt(raw));
    }
    return node;
}
 
开发者ID:line,项目名称:centraldogma,代码行数:17,代码来源:RemoveOperation.java


示例2: findByCohort

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
/**
 * Traverses the argument {@link JsonNode} to find any contained
 * {@code JsonNode JsonNodes} which match the argument cohort, if
 * present.
 *
 * If {@code node} is an {@code ArrayNode}, then the array is
 * traversed and the first matching filter node, if any, is
 * returned.
 *
 * @param node A {@code JsonNode} to traverse in search of cohort
 *        information.
 * @param cohortOpt An optional cohort string to match against the
 *        argument {@code JsonNode}.
 * @return A {@code JsonNode} matching the specified cohort, or else
 *         {@link MissingNode}.
 */
public static JsonNode findByCohort(JsonNode node, Optional<String> cohortOpt) {
  if (node.isObject() && ToggleJsonNode.matchesCohort(node, cohortOpt)) {
    return node;
  } else if (node.isArray()) {
    final Iterator<JsonNode> iterator = node.elements();

    while (iterator.hasNext()) {
      final JsonNode containedNode = iterator.next();
      if (containedNode.isObject() && ToggleJsonNode.matchesCohort(containedNode, cohortOpt)) {
        return containedNode;
      }
    }

    return MissingNode.getInstance();
  } else {
    return MissingNode.getInstance();
  }
}
 
开发者ID:whiskerlabs,项目名称:toggle,代码行数:35,代码来源:ToggleJsonNode.java


示例3: searchKey

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
/**
 * Recursively search for the JsonNode for the specified key. If found, this function will return an ObjectNode containing the key with underlying JsonNode.
 * For instance, if searching for "key2" in JSON "{key1:{key2:{key3:value}}}" this will return "{key2:{key3:value}}"
 * @param jn the JsonNode to search in
 * @param key the key to search for
 * @return the found object with {key:JsonNode} or MissingNode if not found
 */
public JsonNode searchKey(JsonNode jn, String key){
	//this is a null node or a leaf node
	if(jn == null || !jn.isContainerNode()) {
		return MissingNode.getInstance();
	}
	
	//yay, found it!
	//extract value and place it in clean wrapper ObjectNode with the key
	if(jn.has(key)) {
		return om.createObjectNode().set(key, jn.get(key));
	}
	
	//not found on this level... try to go deeper
	for (JsonNode child : jn) {
		if (child.isContainerNode()) {
		    JsonNode childResult = searchKey(child, key);
		    if (childResult != null && !childResult.isMissingNode()) {
		        return childResult;
		    }
		}
	}
	
	// not found at all
	return MissingNode.getInstance();
}
 
开发者ID:ArticulatedSocialAgentsPlatform,项目名称:HmiCore,代码行数:33,代码来源:JSONHelper.java


示例4: push

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
/**
 * Build an array of email subscribers and batch insert via bulk MailChimp API
 * Reference: https://developer.mailchimp.com/documentation/mailchimp/reference/lists/#create-post_lists_list_id
 *
 * @param node the data
 * @param task the task
 * @return the report response
 * @throws JsonProcessingException the json processing exception
 */
ReportResponse push(final ObjectNode node, PluginTask task)
        throws JsonProcessingException
{
    String endpoint = MessageFormat.format(mailchimpEndpoint + "/lists/{0}",
                                           task.getListId());

    JsonNode response = client.sendRequest(endpoint, HttpMethod.POST, node.toString(), task);
    client.avoidFlushAPI("Process next request");

    if (response instanceof MissingNode) {
        ReportResponse reportResponse = new ReportResponse();
        reportResponse.setErrors(new ArrayList<ErrorResponse>());
        return reportResponse;
    }

    return mapper.treeToValue(response, ReportResponse.class);
}
 
开发者ID:treasure-data,项目名称:embulk-output-mailchimp,代码行数:27,代码来源:MailChimpClient.java


示例5: deserialize

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
@Override
public Resource deserialize(JsonParser parser, DeserializationContext context) throws IOException {
  TreeNode tree = parser.readValueAsTree();
  Assert.isTrue(tree.path("rClass") != MissingNode.getInstance(),
      "No 'rClass' field found. Cannot deserialize Resource JSON.");
  RClass rClass = modelService.resolveRType(((TextNode) tree.path("rClass")).textValue());
  if (rClass.isAbstract()) {
    throw new AbstractRClassException(rClass);
  }
  Resource resource = factory.createResource(rClass);
  TreeNode properties = tree.path("properties");
  if (properties instanceof ObjectNode) {
    populateProperties((ObjectNode) properties, resource);
  }
  return resource;
}
 
开发者ID:lfridael,项目名称:resourceful-java-prototype,代码行数:17,代码来源:ResourceDeserializer.java


示例6: fromString

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
/**
 * Constructs a {@link JsonNode} from a JSON string.
 *
 * @param json A string encoding a JSON object
 * @return A {@code JsonNode} if the argument string is valid, otherwise
 *         {@link MissingNode}.
 */
public static JsonNode fromString(String json) {
  try {
    return DEFAULT_OBJECT_READER.readTree(json);
  } catch (IOException err) {
    return MissingNode.getInstance();
  }
}
 
开发者ID:whiskerlabs,项目名称:toggle,代码行数:15,代码来源:ToggleJsonNode.java


示例7: getJson

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
public JsonNode getJson() {
	if (isValid()) {
		return json;
	} else {
		return MissingNode.getInstance();
	}
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:8,代码来源:Reference.java


示例8: osDiskStatus

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
@Override
public EncryptionStatus osDiskStatus() {
    if (!hasEncryptionExtension()) {
        return EncryptionStatus.NOT_ENCRYPTED;
    }
    final JsonNode subStatusNode = instanceViewFirstSubStatus();
    if (subStatusNode == null) {
        return EncryptionStatus.UNKNOWN;
    }
    JsonNode diskNode = subStatusNode.path("os");
    if (diskNode instanceof MissingNode) {
        return EncryptionStatus.UNKNOWN;
    }
    return EncryptionStatus.fromString(diskNode.asText());
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:16,代码来源:LinuxDiskVolumeEncryptionMonitorImpl.java


示例9: dataDiskStatus

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
@Override
public EncryptionStatus dataDiskStatus() {
    if (!hasEncryptionExtension()) {
        return EncryptionStatus.NOT_ENCRYPTED;
    }
    final JsonNode subStatusNode = instanceViewFirstSubStatus();
    if (subStatusNode == null) {
        return EncryptionStatus.UNKNOWN;
    }
    JsonNode diskNode = subStatusNode.path("data");
    if (diskNode instanceof MissingNode) {
        return EncryptionStatus.UNKNOWN;
    }
    return EncryptionStatus.fromString(diskNode.asText());
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:16,代码来源:LinuxDiskVolumeEncryptionMonitorImpl.java


示例10: extractCapturedImageUri

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
private static String extractCapturedImageUri(String capturedResultJson) {
    ObjectMapper mapper = new ObjectMapper();
    JsonNode rootNode;
    try {
        rootNode = mapper.readTree(capturedResultJson);
    } catch (IOException exception) {
        throw new RuntimeException("Parsing JSON failed -" + capturedResultJson, exception);
    }

    JsonNode resourcesNode = rootNode.path("resources");
    if (resourcesNode instanceof MissingNode) {
        throw new IllegalArgumentException("Expected 'resources' node not found in the capture result -" + capturedResultJson);
    }

    String imageUri = null;
    for (JsonNode resourceNode : resourcesNode) {
        JsonNode propertiesNodes = resourceNode.path("properties");
        if (!(propertiesNodes instanceof MissingNode)) {
            JsonNode storageProfileNode = propertiesNodes.path("storageProfile");
            if (!(storageProfileNode instanceof MissingNode)) {
                JsonNode osDiskNode = storageProfileNode.path("osDisk");
                if (!(osDiskNode instanceof MissingNode)) {
                    JsonNode imageNode = osDiskNode.path("image");
                    if (!(imageNode instanceof MissingNode)) {
                        JsonNode uriNode = imageNode.path("uri");
                        if (!(uriNode instanceof MissingNode)) {
                            imageUri = uriNode.asText();
                        }
                    }
                }
            }
        }
    }

    if (imageUri == null) {
        throw new IllegalArgumentException("Could not locate image uri under expected section in the capture result -" + capturedResultJson);
    }
    return imageUri;
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:40,代码来源:CreateVirtualMachinesUsingCustomImageOrSpecializedVHD.java


示例11: get

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
public static PrimitiveObject get( final JsonNode jsonNode ) throws IOException{
  if( jsonNode instanceof TextNode ){
    return new StringObj( ( (TextNode)jsonNode ).textValue() );
  }
  else if( jsonNode instanceof BooleanNode ){
    return new BooleanObj( ( (BooleanNode)jsonNode ).booleanValue() );
  }
  else if( jsonNode instanceof IntNode ){
    return new IntegerObj( ( (IntNode)jsonNode ).intValue() );
  }
  else if( jsonNode instanceof LongNode ){
    return new LongObj( ( (LongNode)jsonNode ).longValue() );
  }
  else if( jsonNode instanceof DoubleNode ){
    return new DoubleObj( ( (DoubleNode)jsonNode ).doubleValue() );
  }
  else if( jsonNode instanceof BigIntegerNode ){
    return new StringObj( ( (BigIntegerNode)jsonNode ).bigIntegerValue().toString() );
  }
  else if( jsonNode instanceof DecimalNode ){
    return new StringObj( ( (DecimalNode)jsonNode ).decimalValue().toString() );
  }
  else if( jsonNode instanceof BinaryNode ){
    return new BytesObj( ( (BinaryNode)jsonNode ).binaryValue() );
  }
  else if( jsonNode instanceof POJONode ){
    return new BytesObj( ( (POJONode)jsonNode ).binaryValue() );
  }
  else if( jsonNode instanceof NullNode ){
    return NullObj.getInstance();
  }
  else if( jsonNode instanceof MissingNode ){
    return NullObj.getInstance();
  }
  else{
    return new StringObj( jsonNode.toString() );
  }
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:39,代码来源:JsonNodeToPrimitiveObject.java


示例12: shouldReturnBaseClaimWhenParsingMissingNode

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
@Test
public void shouldReturnBaseClaimWhenParsingMissingNode() throws Exception {
    JsonNode value = MissingNode.getInstance();
    Claim claim = claimFromNode(value);

    assertThat(claim, is(notNullValue()));
    assertThat(claim, is(instanceOf(NullClaim.class)));
    assertThat(claim.isNull(), is(true));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:10,代码来源:JsonNodeClaimTest.java


示例13: checkContextData

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
private static void checkContextData(LogEvent logEvent, String mdcKeyRegex, final JsonNode rootNode) {
    final Pattern mdcKeyPattern = mdcKeyRegex == null ? null : Pattern.compile(mdcKeyRegex);
    logEvent.getContextData().forEach(new BiConsumer<String, Object>() {
        @Override
        public void accept(String key, Object value) {
            JsonNode node = point(rootNode, "mdc", key);
            boolean matches = mdcKeyPattern == null || mdcKeyPattern.matcher(key).matches();
            if (matches) {
                assertThat(node.asText()).isEqualTo(value);
            } else {
                assertThat(node).isEqualTo(MissingNode.getInstance());
            }
        }
    });
}
 
开发者ID:vy,项目名称:log4j2-logstash-layout,代码行数:16,代码来源:LogstashLayoutTest.java


示例14: evaluate

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
@Override
public JsonNode evaluate(FunctionArgs args, EvaluationContext context) {
    final String value = valueParam.required(args, context);
    try {
        return objectMapper.readTree(value);
    } catch (IOException e) {
        log.warn("Unable to parse JSON", e);
    }
    return MissingNode.getInstance();
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:11,代码来源:JsonParse.java


示例15: createNodeMatcher

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
private static Matcher<JsonNode> createNodeMatcher(final JsonNode value) {
  final JsonNodeType nodeType = value.getNodeType();
  switch (nodeType) {
    case ARRAY:
      return IsJsonArray.jsonArray((ArrayNode) value);
    case BINARY:
      throw new UnsupportedOperationException(
          "Expected value contains a binary node, which is not implemented.");
    case BOOLEAN:
      return IsJsonBoolean.jsonBoolean((BooleanNode) value);
    case MISSING:
      return IsJsonMissing.jsonMissing((MissingNode) value);
    case NULL:
      return IsJsonNull.jsonNull((NullNode) value);
    case NUMBER:
      return IsJsonNumber.jsonNumber((NumericNode) value);
    case OBJECT:
      return IsJsonObject.jsonObject((ObjectNode) value);
    case POJO:
      throw new UnsupportedOperationException(
          "Expected value contains a POJO node, which is not implemented.");
    case STRING:
      return IsJsonText.jsonText((TextNode) value);
    default:
      throw new UnsupportedOperationException("Unsupported node type " + nodeType);
  }
}
 
开发者ID:spotify,项目名称:java-hamcrest,代码行数:28,代码来源:IsJsonObject.java


示例16: decode

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
/**
 * Attempt to decode the input as JSON. Returns the {@link JsonNode} if
 * the decode is successful.
 *
 * If the decode fails and the {@code failQuietly} flag is true, returns a
 * {@link MissingNode}. Otherwise an {@link IllegalArgumentException} will
 * be thrown.
 */
public static JsonNode decode(String input, boolean failQuietly) {
  try {
    return MAPPER.readTree(input);
  } catch (IOException e) {
    if (failQuietly) {
      return MissingNode.getInstance();
    }
    throw new IllegalArgumentException("Unable to decode JSON", e);
  }
}
 
开发者ID:Squarespace,项目名称:template-compiler,代码行数:19,代码来源:JsonUtils.java


示例17: get

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
/**
 * Uses a String path to create a List of keys in order to move
 * through a nested ${@link JsonNode} in order to find a specific
 * value. If the value is found, it is returned. If it can not be
 * found, a ${@link MissingNode} will be returned.
 *
 * @param node the node to use for the search
 * @param path the path to find the value for
 * @return a ${@link JsonNode} if found, a ${@link MissingNode} if not
 * @throws ParseException if any parsing issues occur
 */
public static JsonNode get(JsonNode node, String path) throws ParseException {
    // check for bad targets
    if (node == null) {
        return MissingNode.getInstance();
    }

    // create a list of keys from the path
    List<NotedKey> keys = keys(path);

    // store a cheap reference
    JsonNode tmp = node;

    // grab length
    int lastIndex = keys.size() - 1;

    // go through every key we have (except the last)
    for(int i = 0; i < lastIndex; i++) {
        tmp = DotUtils.findNode(tmp, keys.get(i));
        // if we've hit a dead end
        if (tmp.isMissingNode() || tmp.isNull()) {
            // short-circuit
            return tmp;
        }
    }

    // get the last key from the list
    NotedKey key = keys.get(lastIndex);

    // if the key is a Number
    if (key.isNumber()) {
        // return the ArrayNode index
        return tmp.path(key.asNumber());
    }

    // return the ObjectNode value
    return tmp.path(key.asString());
}
 
开发者ID:whitfin,项目名称:dot-notes-java,代码行数:49,代码来源:DotNotes.java


示例18: iteratesMissingValues

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
@Test
public void iteratesMissingValues() throws Exception {
    final ObjectNode objectNode = factory.objectNode();

    objectNode.set("test", MissingNode.getInstance());

    final int[] iterator = new int[]{0};

    DotNotes.recurse(objectNode, new DotNotes.NodeIterator() {
        @Override
        protected void execute(NotedKey key, JsonNode value, String path) {
            iterator[0]++;

            assertNotNull(key);
            assertTrue(key.isString());
            assertEquals(key.asString(), "test");

            assertNotNull(value);
            assertTrue(value.isMissingNode());

            assertNotNull(path);
            assertEquals(path, "test");
        }
    });

    assertEquals(iterator[0], 1);
}
 
开发者ID:whitfin,项目名称:dot-notes-java,代码行数:28,代码来源:RecurseTest.java


示例19: locateNode

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
private static JsonNode locateNode(JsonNode tree, DecoderColumnHandle columnHandle)
{
    String mapping = columnHandle.getMapping();
    checkState(mapping != null, "No mapping for %s", columnHandle.getName());

    JsonNode currentNode = tree;
    for (String pathElement : Splitter.on('/').omitEmptyStrings().split(mapping)) {
        if (!currentNode.has(pathElement)) {
            return MissingNode.getInstance();
        }
        currentNode = currentNode.path(pathElement);
    }
    return currentNode;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:15,代码来源:JsonRowDecoder.java


示例20: locateNode

import com.fasterxml.jackson.databind.node.MissingNode; //导入依赖的package包/类
private static JsonNode locateNode(JsonNode tree, KinesisColumnHandle columnHandle)
{
    String mapping = columnHandle.getMapping();
    checkState(mapping != null, "No mapping for %s", columnHandle.getName());

    JsonNode currentNode = tree;
    for (String pathElement : Splitter.on('/').omitEmptyStrings().split(mapping)) {
        if (!currentNode.has(pathElement)) {
            return MissingNode.getInstance();
        }
        currentNode = currentNode.path(pathElement);
    }
    return currentNode;
}
 
开发者ID:qubole,项目名称:presto-kinesis,代码行数:15,代码来源:JsonKinesisRowDecoder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SerialPipes类代码示例发布时间:2022-05-21
下一篇:
Java ObservableRecyclerView类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap