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


Java JsonNode.isMissingNode方法代码示例

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


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

示例1: setInPath

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public JsonNode setInPath(JsonNode container, JsonNode value) {
	if (this.path.matches()) {
		if (container.isMissingNode()) {
			return value;
		} else if (canMerge(container, value, null)) {
			return merge(container, value, null);
		} else if (canAdd(container, value)) {
			return add(container, value);
		} else {
			throw badStructure();
		}
	} else if (container.isObject() || container.isMissingNode()) {
		container = container.isMissingNode() ? JsonOverlay.jsonObject() : container;
		setInPath((ObjectNode) container, this.path, value);
		return container;
	} else {
		throw badStructure();
	}
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:20,代码来源:JsonPath.java

示例2: validate

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public void validate(T object, ValidationResults results, Set<Class<? extends JsonNode>> allowedNodeTypes) {
	JsonOverlay<?> overlay = (JsonOverlay<?>) object;
	JsonNode json = overlay.toJson();
	boolean isValidJsonType = false;
	for (Class<? extends JsonNode> type : allowedNodeTypes) {
		if (type.isAssignableFrom(json.getClass())) {
			isValidJsonType = true;
			break;
		}
	}
	isValidJsonType = isValidJsonType || json.isMissingNode();
	if (!isValidJsonType) {
		results.addError(m.msg("WrongTypeJson|Property bound to incompatible JSON Node type", json.getNodeType(),
				allowedNodeTypes));
	}
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:17,代码来源:OverlayValidator.java

示例3: apply

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Toggle<T> apply(String key) {
  final JsonNode toggleNode =
    ToggleJsonNode.findByKey(jsonNodeSupplier.get(), key);

  if (toggleNode.isMissingNode()) {
    // TODO: Log the error.
    throw new NoSuchElementException(Toggle.UNABLE_TO_LOOK_UP_KEY_PREFIX + key);
  }

  return new Toggle<T>() {
    @Override
    protected boolean test(T t, Optional<String> cohortOpt) {
      final JsonNode filterNode =
      ToggleJsonNode.findByCohort(toggleNode.path("filter"), cohortOpt);

      if (filterNode.isMissingNode()) {
        // No filter found for cohort. Weight result by default value.
        return nextBoolean(toggleNode.path("value").intValue());
      } else {
        // Filter found for cohort. Weight result by the filter's value.
        return nextBoolean(filterNode.path("value").intValue());
      }
    }
  };
}
 
开发者ID:whiskerlabs,项目名称:toggle,代码行数:27,代码来源:JsonToggleMap.java

示例4: parseJsonNode

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * 可以取出类似与fastjson JSONObject类似的一个node tree
 * path 为null时候 返回为 root json node
 * 例如:{"a":"a1","b":"b1","c":{"d":"d1","e":"e2"}}
 * 当path为null或者空时 返回jsonnode为:{"a":"a1","b":"b1","c":{"d":"d1","e":"e2"}}
 * 房path为c 返回jsonnode为: {"d":"d1","e":"e2"}
 *
 * @param json  json串
 * @param paths json key 路径path
 * @return
 */
public static JsonNode parseJsonNode(@NotNull String json, @Nullable String... paths) {
    try {
        JsonNode rootNode = objectMapper.readTree(json);
        if (!Check.isNullOrEmpty(paths)) {
            for (String pt : paths) {
                rootNode = rootNode.path(pt);
                //如果不存在
                if (rootNode.isMissingNode()) {
                    return null;
                }
            }
        }
        return rootNode;
    } catch (IOException e) {
        throw new JsonTransformException("Json获取JsonNode时出现异常。", e);
    }
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:29,代码来源:Json.java

示例5: getList

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Gets the specified array property as a list of items.
 *
 * @param name     property name
 * @param function mapper from string to item
 * @param defaultValue default value if property not set
 * @param <T>      type of item
 * @return list of items
 */
protected <T> List<T> getList(String name, Function<String, T> function, List<T> defaultValue) {
    List<T> list = Lists.newArrayList();
    JsonNode jsonNode = object.path(name);
    if (jsonNode.isMissingNode()) {
        return defaultValue;
    }
    ArrayNode arrayNode = (ArrayNode) jsonNode;
    arrayNode.forEach(i -> list.add(function.apply(i.asText())));
    return list;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:Config.java

示例6: updateDatasetTags

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void updateDatasetTags(JsonNode root)
    throws Exception {
  final JsonNode tags = root.path("tags");
  if (tags.isMissingNode() || !tags.isArray()) {
    throw new IllegalArgumentException(
        "Dataset tag info update error, missing necessary fields: " + root.toString());
  }

  final Object[] idUrn = findDataset(root);
  if (idUrn[0] == null || idUrn[1] == null) {
    throw new IllegalArgumentException("Cannot identify dataset from id/uri/urn: " + root.toString());
  }
  final Integer datasetId = (Integer) idUrn[0];
  final String urn = (String) idUrn[1];

  for (final JsonNode tag : tags) {
    DatasetTagRecord record = new DatasetTagRecord();
    record.setTag(tag.asText());
    record.setDatasetId(datasetId);
    record.setDatasetUrn(urn);
    record.setModifiedTime(System.currentTimeMillis() / 1000);
    TAG_WRITER.append(record);
  }

  // remove old info then insert new info
  TAG_WRITER.execute(DELETE_DATASET_TAG_BY_DATASET_ID, new Object[]{datasetId});
  TAG_WRITER.insert();
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:29,代码来源:DatasetInfoDao.java

示例7: getInterfaces

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Returns the list of interfaces enabled on this router.
 *
 * @return list of interface names that are enabled, or an empty list if
 * all available interfaces should be used
 */
public List<String> getInterfaces() {
    JsonNode intfNode = object.path(INTERFACES);
    if (intfNode.isMissingNode() || !intfNode.isArray()) {
        return Collections.emptyList();
    }
    ArrayNode array = (ArrayNode) intfNode;
    List<String> interfaces = new ArrayList<>(array.size());
    for (JsonNode intf : array) {
        interfaces.add(intf.asText());
    }
    return interfaces;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:RouterConfig.java

示例8: updateDatasetReference

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void updateDatasetReference(JsonNode root)
    throws Exception {
  final JsonNode references = root.path("references");
  if (references.isMissingNode() || !references.isArray()) {
    throw new IllegalArgumentException(
        "Dataset reference info update fail, missing necessary fields: " + root.toString());
  }

  final Object[] idUrn = findDataset(root);
  if (idUrn[0] == null || idUrn[1] == null) {
    throw new IllegalArgumentException("Cannot identify dataset from id/uri/urn: " + root.toString());
  }
  final Integer datasetId = (Integer) idUrn[0];
  final String urn = (String) idUrn[1];

  ObjectMapper om = new ObjectMapper();

  for (final JsonNode reference : references) {
    DatasetReferenceRecord record = om.convertValue(reference, DatasetReferenceRecord.class);
    record.setDatasetId(datasetId);
    record.setDatasetUrn(urn);
    record.setModifiedTime(System.currentTimeMillis() / 1000);
    REFERENCE_WRITER.append(record);
  }

  // remove old info then insert new info
  REFERENCE_WRITER.execute(DELETE_DATASET_REFERENCE_BY_DATASET_ID, new Object[]{datasetId});
  REFERENCE_WRITER.insert();
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:30,代码来源:DatasetInfoDao.java

示例9: claimFromNode

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Helper method to create a Claim representation from the given JsonNode.
 *
 * @param node the JsonNode to convert into a Claim.
 * @return a valid Claim instance. If the node is null or missing, a NullClaim will be returned.
 */
static Claim claimFromNode(JsonNode node) {
    if (node == null || node.isNull() || node.isMissingNode()) {
        return new NullClaim();
    }
    return new JsonNodeClaim(node);
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:13,代码来源:JsonNodeClaim.java

示例10: speed

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Returns the port speed configured for this port. If the port doesn't have
 * a notion of speed, this returns an empty Optional.
 *
 * @return a port speed value whose default is 0.
 */
public Optional<Integer> speed() {
    JsonNode s = object.path(SPEED);
    if (s.isMissingNode()) {
        return Optional.empty();
    }
    return Optional.of(s.asInt());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:OpticalPortConfig.java

示例11: updateDatasetInventory

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void updateDatasetInventory(JsonNode root)
    throws Exception {
  final JsonNode auditHeader = root.path("auditHeader");
  final JsonNode dataPlatform = root.path("dataPlatformUrn");
  final JsonNode datasetList = root.path("datasetList");

  if (auditHeader.isMissingNode() || dataPlatform.isMissingNode() || datasetList.isMissingNode()) {
    throw new IllegalArgumentException(
        "Dataset inventory info update fail, " + "Json missing necessary fields: " + root.toString());
  }

  final Long eventTime = auditHeader.get("time").asLong();
  final String eventDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date(eventTime));
  final String dataPlatformUrn = dataPlatform.asText();

  final ObjectMapper om = new ObjectMapper();

  for (JsonNode datasetItem : datasetList) {
    try {
      DatasetInventoryItemRecord item = om.convertValue(datasetItem, DatasetInventoryItemRecord.class);
      item.setDataPlatformUrn(dataPlatformUrn);
      item.setEventDate(eventDate);
      INVENTORY_WRITER.execute(INSERT_DATASET_INVENTORY_ITEM, item.getInventoryItemValues());
    } catch (Exception ex) {
      Logger.debug("Dataset inventory item insertion error. ", ex);
    }
  }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:29,代码来源:DatasetInfoDao.java

示例12: ensureExistence

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
JsonNode ensureExistence(JsonNode node) {
    final JsonNode found = node.at(path);
    if (found.isMissingNode()) {
        throw new JsonPatchException("non-existent path: " + path);
    }
    return found;
}
 
开发者ID:line,项目名称:centraldogma,代码行数:8,代码来源:JsonPatchOperation.java

示例13: getLifeEnvironmentVariables

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public ObjectNode getLifeEnvironmentVariables () {

		ObjectNode vars = getAttributeAsObject( ServiceAttributes.environmentVariables );

		if ( vars != null ) {
			JsonNode lifeJson = vars.at( "/lifecycle/" + Application.getCurrentLifeCycle() );
			if ( !lifeJson.isMissingNode() && lifeJson.isObject() ) {
				return (ObjectNode) lifeJson;
			}
		}
		return jacksonMapper.createObjectNode();
	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:13,代码来源:ServiceBaseParser.java

示例14: updateDatasetPartition

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void updateDatasetPartition(JsonNode root)
    throws Exception {
  final JsonNode partition = root.path("partitionSpec");
  if (partition.isMissingNode() || partition.isNull()) {
    throw new IllegalArgumentException(
        "Dataset reference info update fail, missing necessary fields: " + root.toString());
  }

  final Object[] idUrn = findDataset(root);
  if (idUrn[0] == null || idUrn[1] == null) {
    throw new IllegalArgumentException("Cannot identify dataset from id/uri/urn: " + root.toString());
  }
  final Integer datasetId = (Integer) idUrn[0];
  final String urn = (String) idUrn[1];

  ObjectMapper om = new ObjectMapper();

  DatasetPartitionRecord record = om.convertValue(partition, DatasetPartitionRecord.class);
  record.setDatasetId(datasetId);
  record.setDatasetUrn(urn);
  record.setModifiedTime(System.currentTimeMillis() / 1000);
  try {
    DatasetPartitionRecord result = getDatasetPartitionByDatasetId(datasetId);
    String[] columns = record.getDbColumnNames();
    Object[] columnValues = record.getAllValuesToString();
    String[] conditions = {"dataset_id"};
    Object[] conditionValues = new Object[]{datasetId};
    PARTITION_WRITER.update(columns, columnValues, conditions, conditionValues);
  } catch (EmptyResultDataAccessException ex) {
    PARTITION_WRITER.append(record);
    PARTITION_WRITER.insert();
  }

  // update dataset field partitioned
  if (record.getPartitionKeys() != null) {
    for (DatasetPartitionKeyRecord partitionKey : record.getPartitionKeys()) {
      List<String> fieldNames = partitionKey.getFieldNames();
      for (String fieldName : fieldNames) {
        FIELD_DETAIL_WRITER.execute(UPDATE_DATASET_FIELD_PARTITIONED_BY_FIELDNAME,
            new Object[]{"Y", datasetId, fieldName});
      }
    }
  }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:45,代码来源:DatasetInfoDao.java

示例15: fileBrowser

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@RequestMapping ( "/browser/{browseId}" )
public String fileBrowser (
							@PathVariable ( value = "browseId" ) String browseId,
							@RequestParam ( value = "showDu" , required = false ) String showDu,
							ModelMap modelMap, HttpServletRequest request, HttpSession session, PrintWriter writer ) {

	setCommonAttributes( modelMap, session, "File Browser" );
	JsonNode browseSettings = getBrowseSettings( browseId );

	if ( browseSettings.isMissingNode()
			|| !browseSettings.has( "group" ) ) {
		// logger.info( "settingsNode: {}", settingsNode );
		writer.println( "requested browse group not found: " + browseId );
		writer.println( "Contact administrator" );
		return null;
	}

	if ( Application.isJvmInManagerMode() ) {
		// csapApp.getRootModel().getAllPackagesModel().getServiceInstances(
		// serviceName )

		String cluster = browseSettings.get( "cluster" ).asText().replace( "-", "" );
		ArrayList<String> clusterHosts = csapApp.getActiveModel().getAllPackagesModel()
			.getLcGroupVerToHostMap().get( cluster );

		logger.debug( "specified: {}, Keys: {}", cluster, csapApp.getActiveModel().getAllPackagesModel()
			.getLcGroupVerToHostMap().keySet() );

		if ( clusterHosts == null || clusterHosts.size() == 0 ) {
			writer.println( "Incorrect browser configuration - very settings: " + browseSettings.get( "cluster" ).asText() );
			return null;
		}
		return "redirect:" + csapApp.getAgentUrl( clusterHosts.get( 0 ), "/file/browser/" + browseId, false );
	}

	csapSecurityConfiguration.addRoleIfUserHasAccess( session, browseSettings.get( "group" ).asText() );
	if ( !hasBrowseAccess( session, browseId ) ) {
		logger.info( "Permission denied for accessing {}, Confirm: {} is a member of: {}",
			browseId, csapSecurityConfiguration.getUserIdFromContext(),
			browseSettings.get( "group" ).asText() );
		return "csap/security/accessError";
	}

	modelMap.addAttribute( "serviceName", null );
	modelMap.addAttribute( "browseId", browseId );
	modelMap.addAttribute( "browseGroup", getBrowseSettings( browseId ).get( "group" ).asText() );

	modelMap.addAttribute( "fromFolder", Application.FileToken.ROOT.value );

	return CsapCoreService.FILE_URL + "/file-browser";
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:52,代码来源:FileRequests.java


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