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


Java JsonNode.toString方法代码示例

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


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

示例1: getTemplate

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static String getTemplate() throws IllegalAccessException, JsonProcessingException, IOException {
    final String hostingPlanName = SdkContext.randomResourceName("hpRSAT", 24);
    final String webappName = SdkContext.randomResourceName("wnRSAT", 24);
    final InputStream embeddedTemplate;
    embeddedTemplate = DeployUsingARMTemplate.class.getResourceAsStream("/templateValue.json");

    final ObjectMapper mapper = new ObjectMapper();
    final JsonNode tmp = mapper.readTree(embeddedTemplate);

    DeployUsingARMTemplate.validateAndAddFieldValue("string", hostingPlanName, "hostingPlanName", null, tmp);
    DeployUsingARMTemplate.validateAndAddFieldValue("string", webappName, "webSiteName", null, tmp);
    DeployUsingARMTemplate.validateAndAddFieldValue("string", "F1", "skuName", null, tmp);
    DeployUsingARMTemplate.validateAndAddFieldValue("int", "1", "skuCapacity", null, tmp);

    return tmp.toString();
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:17,代码来源:DeployUsingARMTemplate.java

示例2: getTemplate

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static String getTemplate() throws IllegalAccessException, JsonProcessingException, IOException {
    final String adminUsername = "tirekicker";
    final String adminPassword = "12NewPA$$w0rd!";
    final String osDiskName = SdkContext.randomResourceName("osdisk-", 24);

    final InputStream embeddedTemplate;
    embeddedTemplate = DeployVirtualMachineUsingARMTemplate.class.getResourceAsStream("/virtualMachineWithManagedDisksTemplate.json");

    final ObjectMapper mapper = new ObjectMapper();
    final JsonNode tmp = mapper.readTree(embeddedTemplate);

    DeployVirtualMachineUsingARMTemplate.validateAndAddFieldValue("string", adminUsername, "adminUsername", null, tmp);
    DeployVirtualMachineUsingARMTemplate.validateAndAddFieldValue("string", adminPassword, "adminPassword", null, tmp);
    DeployVirtualMachineUsingARMTemplate.validateAndAddFieldValue("string", osDiskName, "osDiskName", null, tmp);
    return tmp.toString();
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:17,代码来源:DeployVirtualMachineUsingARMTemplate.java

示例3: isJsonNodeSubset

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Returns true if expected is a subset of returned
 *
 * This is used for JSON serialiser comparisons. This is taken from
 * the 'equals' definition of JsonNode's, but without the length check
 * on the list of children nodes, plus location reporting.
 *
 * @param expected
 * @param returned
 * @return
 */
protected boolean isJsonNodeSubset(JsonNode expected, JsonNode returned) {

    if (returned == null) {
	errorDescription = "Returned value is null, expected JSON:\n" + expected.toString();
	return false;
    }
    if (returned == expected) return true;

    if (returned.getClass() != expected.getClass()) {
	errorDescription = "Returned value class is incorrect, expected JSON: " + expected.toString()
	+ ", returned JSON: " + returned.toString();
	return false;
    }

    switch (expected.getNodeType()) {
	case ARRAY: 	return isArrayNodeSubset((ArrayNode)expected, (ArrayNode)returned);
	case OBJECT: 	return isObjectNodeSubset((ObjectNode)expected, (ObjectNode)returned);
	default: 		return isValueEqual((ValueNode)expected, (ValueNode)returned);	// Will be a ValueNode subclass
    }
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:32,代码来源:SubsetStatus.java

示例4: deserializeEncryptedShard

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static EncryptedShard deserializeEncryptedShard(final byte[] publicKeyBytes, @NotNull final JsonNode shard) {
    byte[] encryptedKeyShardBytes = base64StringToBytes(requireStringValue(shard, ENCRYPTED_SHARD_NAME));
    final JsonNode symmetricKeyNode = shard.get(ENCRYPTED_SYMMETRIC_KEY_NAME);
    final JsonNode symmetricEncryptionAlgorithmNode = shard.get(SYMMETRIC_ENCRYPTION_NAME);
    if (symmetricKeyNode == null && symmetricEncryptionAlgorithmNode == null) {
        return new EncryptedShard(publicKeyBytes, encryptedKeyShardBytes);
    } else if (symmetricKeyNode != null && symmetricEncryptionAlgorithmNode != null) {
        byte[] encryptedSymmetricKey = base64StringToBytes(symmetricKeyNode.asText());
        SymmetricEncryptionAlgorithm symmetricEncryptionAlgorithm = SymmetricEncryptionAlgorithm.valueOf(symmetricEncryptionAlgorithmNode.asText());
        return new EncryptedShard(publicKeyBytes, encryptedKeyShardBytes, symmetricEncryptionAlgorithm, encryptedSymmetricKey);
    } else {
        @NotNull final String msg = ENCRYPTED_SYMMETRIC_KEY_NAME + " and " + SYMMETRIC_ENCRYPTION_NAME
                                            + " must either be both specified or both not specified " + shard.toString();
        throw new RuntimeException(msg);
    }
}
 
开发者ID:mgrand,项目名称:crypto-shuffle,代码行数:17,代码来源:JsonUtil.java

示例5: editProps

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static String editProps(String ogPropString, String ygPropString) throws IOException {
  JsonNode ogPropNode = Json.parse(ogPropString);
  JsonNode ygPropNode = Json.parse(ygPropString);

  Iterator<Map.Entry<String, JsonNode>> ygPropIter = ygPropNode.fields();

  while (ygPropIter.hasNext()) {
    Entry<String,JsonNode> field = ygPropIter.next();
    if (field.getKey() != "urn") {
      ((ObjectNode) ogPropNode).put(field.getKey(), field.getValue());
    }
  }
  return ogPropNode.toString();
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:15,代码来源:DatasetDao.java

示例6: updateDatasetDeployment

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void updateDatasetDeployment(JsonNode root)
    throws Exception {
  final JsonNode deployment = root.path("deploymentInfo");
  if (deployment.isMissingNode() || !deployment.isArray()) {
    throw new IllegalArgumentException(
        "Dataset deployment 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];

  ObjectMapper om = new ObjectMapper();
  // om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);

  for (final JsonNode deploymentInfo : deployment) {
    DeploymentRecord record = om.convertValue(deploymentInfo, DeploymentRecord.class);
    record.setDatasetId(datasetId);
    record.setDatasetUrn(urn);
    record.setModifiedTime(System.currentTimeMillis() / 1000);
    DEPLOYMENT_WRITER.append(record);
  }

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

示例7: getDateFromJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Parse a json node in order to create a Date object
 *
 * @param jsonNode json to parse to Date
 * @return null if a ParseException has been thrown, else the Date object created
 * @throws NullPointerException if jsonNode is null
 */
static Date getDateFromJson(JsonNode jsonNode) {
    Objects.requireNonNull(jsonNode);
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss-SSS");
    TimeZone tz = TimeZone.getTimeZone("CET");
    String timeString = jsonNode.toString();
    timeString = timeString.substring(1, timeString.length() - 4);
    dateFormat.setTimeZone(tz);
    try {
        return dateFormat.parse(timeString);
    } catch (ParseException err) {
        LOGGER.error(err.getMessage());
        return null;
    }
}
 
开发者ID:IKB4Stream,项目名称:IKB4Stream,代码行数:22,代码来源:FacebookMock.java

示例8: 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

示例9: updateDatasetCaseSensitivity

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void updateDatasetCaseSensitivity(JsonNode root)
    throws Exception {
  final JsonNode properties = root.path("datasetProperties");
  if (properties.isMissingNode() || properties.isNull()) {
    throw new IllegalArgumentException(
        "Dataset properties update fail, missing necessary fields: " + root.toString());
  }
  final JsonNode caseSensitivity = properties.path("caseSensitivity");
  if (caseSensitivity.isMissingNode() || caseSensitivity.isNull()) {
    throw new IllegalArgumentException(
        "Dataset properties 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();

  DatasetCaseSensitiveRecord record = om.convertValue(caseSensitivity, DatasetCaseSensitiveRecord.class);
  record.setDatasetId(datasetId);
  record.setDatasetUrn(urn);
  record.setModifiedTime(System.currentTimeMillis() / 1000);
  try {
    DatasetCaseSensitiveRecord result = getDatasetCaseSensitivityByDatasetId(datasetId);
    String[] columns = record.getDbColumnNames();
    Object[] columnValues = record.getAllValuesToString();
    String[] conditions = {"dataset_id"};
    Object[] conditionValues = new Object[]{datasetId};
    CASE_SENSITIVE_WRITER.update(columns, columnValues, conditions, conditionValues);
  } catch (EmptyResultDataAccessException ex) {
    CASE_SENSITIVE_WRITER.append(record);
    CASE_SENSITIVE_WRITER.insert();
  }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:39,代码来源:DatasetInfoDao.java

示例10: 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

示例11: requireValue

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static JsonNode requireValue(@NotNull final JsonNode node, final String fieldName) {
    final JsonNode valueNode = node.get(fieldName);
    if (valueNode == null) {
        @NotNull String msg = "Value of " + fieldName + " must be specified in JSON for a KeyShardSet: " + node.toString();
        throw new RuntimeException(msg);
    }
    return valueNode;
}
 
开发者ID:mgrand,项目名称:crypto-shuffle,代码行数:9,代码来源:JsonUtil.java

示例12: GenericApiGatewayClient

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
GenericApiGatewayClient(ClientConfiguration clientConfiguration, String endpoint, Region region,
                        AWSCredentialsProvider credentials, String apiKey, AmazonHttpClient httpClient) {
    super(clientConfiguration);
    setRegion(region);
    setEndpoint(endpoint);
    this.credentials = credentials;
    this.apiKey = apiKey;
    this.signer = new AWS4Signer();
    this.signer.setServiceName(API_GATEWAY_SERVICE_NAME);
    this.signer.setRegionName(region.getName());

    final JsonOperationMetadata metadata = new JsonOperationMetadata().withHasStreamingSuccessResponse(false).withPayloadJson(false);
    final Unmarshaller<GenericApiGatewayResponse, JsonUnmarshallerContext> responseUnmarshaller = in -> new GenericApiGatewayResponse(in.getHttpResponse());
    this.responseHandler = SdkStructuredPlainJsonFactory.SDK_JSON_FACTORY.createResponseHandler(metadata, responseUnmarshaller);
    JsonErrorUnmarshaller defaultErrorUnmarshaller = new JsonErrorUnmarshaller(GenericApiGatewayException.class, null) {
        @Override
        public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception {
            return new GenericApiGatewayException(jsonContent.toString());
        }
    };
    this.errorResponseHandler = SdkStructuredPlainJsonFactory.SDK_JSON_FACTORY.createErrorResponseHandler(
            Collections.singletonList(defaultErrorUnmarshaller), null);

    if (httpClient != null) {
        super.client = httpClient;
    }
}
 
开发者ID:rpgreen,项目名称:apigateway-generic-java-sdk,代码行数:28,代码来源:GenericApiGatewayClient.java

示例13: updateDatasetIndex

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void updateDatasetIndex(JsonNode root)
    throws Exception {
  final JsonNode indices = root.path("indices");
  if (indices.isMissingNode() || !indices.isArray()) {
    throw new IllegalArgumentException(
        "Dataset indices 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 index : indices) {
    DatasetIndexRecord record = om.convertValue(index, DatasetIndexRecord.class);
    record.setDatasetId(datasetId);
    record.setDatasetUrn(urn);
    record.setModifiedTime(System.currentTimeMillis() / 1000);
    INDEX_WRITER.append(record);

    // update dataset field indexed
    for (DatasetFieldIndexRecord rec : record.getIndexedFields()) {
      String fieldPath = rec.getFieldPath();
      int lastIndex = fieldPath.lastIndexOf('.'); // if not found, index = -1
      String fieldName = fieldPath.substring(lastIndex + 1);
      FIELD_DETAIL_WRITER.execute(UPDATE_DATASET_FIELD_INDEXED_BY_FIELDNAME, new Object[]{"Y", datasetId, fieldName});
    }
  }

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

示例14: 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

示例15: searchEvents

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Parse JSON from Open Agenda API get by the URL
 *
 * @param is     Stream of {@link Event} from OpenAgenda
 * @param source Name of source of this data
 * @return a list of {@link Event}
 * @throws NullPointerException if is or source is null
 * @see Event
 */
default List<Event> searchEvents(InputStream is, String source) {
    Objects.requireNonNull(is);
    Objects.requireNonNull(source);
    List<Event> events = new ArrayList<>();
    ObjectMapper mapper = new ObjectMapper();
    ObjectMapper fieldMapper = new ObjectMapper();
    try {
        JsonNode root = mapper.readTree(is);
        //root
        JsonNode recordsNode = root.path("records");
        for (JsonNode knode : recordsNode) {
            JsonNode fieldsNode = knode.path("fields");
            String transform = "{\"fields\": [" + fieldsNode.toString() + "]}";
            JsonNode rootBis = fieldMapper.readTree(transform);
            JsonNode fieldsRoodNode = rootBis.path("fields");
            for (JsonNode subknode : fieldsRoodNode) {
                String latlon = subknode.path("latlon").toString();
                String title = subknode.path("title").asText();
                String description = subknode.path("description").asText() + " " + subknode.path("free_text").asText();
                String dateStart = subknode.path("date_start").asText();
                String dateEnd = subknode.path("date_end").asText();
                String city = subknode.path("city").asText();
                Event event = createEvent(latlon, title, description, dateStart, dateEnd, city, source);
                pushIfNotNullEvent(events, event);
            }
        }
    } catch (IOException e) {
        LOGGER.error("Bad json format or tree cannot be read: {}", e);
    }
    return events;
}
 
开发者ID:IKB4Stream,项目名称:IKB4Stream,代码行数:41,代码来源:IOpenAgenda.java


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