當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonNode.getTextValue方法代碼示例

本文整理匯總了Java中org.codehaus.jackson.JsonNode.getTextValue方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonNode.getTextValue方法的具體用法?Java JsonNode.getTextValue怎麽用?Java JsonNode.getTextValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.codehaus.jackson.JsonNode的用法示例。


在下文中一共展示了JsonNode.getTextValue方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTrackIdAsString

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
private String getTrackIdAsString(JsonNode trackIDNode)
{
	String output = null;
	if (trackIDNode.isTextual())
		output = trackIDNode.getTextValue();
	else if (trackIDNode.isInt())
		output = Integer.toString(trackIDNode.getIntValue());
	else if (trackIDNode.isLong())
		output = Long.toString(trackIDNode.getLongValue());
	else if (trackIDNode.isDouble())
		output = Double.toString(trackIDNode.getDoubleValue());
	else if (trackIDNode.isFloatingPointNumber())
		output = trackIDNode.getDecimalValue().toString();

	if (!Validator.isEmpty(output))
	{
		output = output.replace("'", "''");
	}
	return output;
}
 
開發者ID:Esri,項目名稱:defense-solutions-proofs-of-concept,代碼行數:21,代碼來源:MLOBIOutboundTransport.java

示例2: testNestedException

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
@Test
public void testNestedException() throws Throwable {
  Exception e =
      new NoRouteToHostException("that box caught fire 3 years ago");
  Exception ioe = new IOException("Datacenter problems", e);
  ThrowableInformation ti = new ThrowableInformation(ioe);
  Log4Json l4j = new Log4Json();
  long timeStamp = Time.now();
  String outcome = l4j.toJson(new StringWriter(),
      "testNestedException",
      timeStamp,
      "INFO",
      "quoted\"",
      "new line\n and {}",
      ti)
      .toString();
  println("testNestedException", outcome);
  ContainerNode rootNode = Log4Json.parse(outcome);
  assertEntryEquals(rootNode, Log4Json.LEVEL, "INFO");
  assertEntryEquals(rootNode, Log4Json.NAME, "testNestedException");
  assertEntryEquals(rootNode, Log4Json.TIME, timeStamp);
  assertEntryEquals(rootNode, Log4Json.EXCEPTION_CLASS,
      ioe.getClass().getName());
  JsonNode node = assertNodeContains(rootNode, Log4Json.STACK);
  assertTrue("Not an array: " + node, node.isArray());
  node = assertNodeContains(rootNode, Log4Json.DATE);
  assertTrue("Not a string: " + node, node.isTextual());
  //rather than try and make assertions about the format of the text
  //message equalling another ISO date, this test asserts that the hypen
  //and colon characters are in the string.
  String dateText = node.getTextValue();
  assertTrue("No '-' in " + dateText, dateText.contains("-"));
  assertTrue("No '-' in " + dateText, dateText.contains(":"));

}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:36,代碼來源:TestLog4Json.java

示例3: makeRequest

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
private String makeRequest(String endpoint, String uri, String requestType) {
    try {
        HttpPost httpPost = new HttpPost(endpoint);
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("url", uri));

        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, Consts.UTF_8);
        httpPost.setEntity(entity);
        HttpResponse response = client.execute(httpPost);

        String result = null;
        String entities = EntityUtils.toString(response.getEntity());
        JsonNode rootNode = new ObjectMapper().readTree(entities).get(requestType);

        switch (requestType) {
            case "similarEntities":
            case "relatedEntities":
                int count = 0;
                result = "";
                for (JsonNode node : rootNode) {
                    count++;
                    if (count <= ResponseData.MAX_DATA_SIZE) {
                        result += "<" + node.get("url").getTextValue() + "> ";
                    }
                    else {
                        break;
                    }
                }
                break;
            case "summary":
                result = rootNode.getTextValue();
                break;
        }
        return result.trim();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:dbpedia,項目名稱:chatbot,代碼行數:41,代碼來源:GenesisService.java

示例4: getBundleVersion

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
/**
 * Get the version of the bundle
 * @param symbolicName bundle symbolic name
 * @return bundle version
 * @throws ClientException if the version is not retrieved
 */
public String getBundleVersion(String symbolicName) throws ClientException {
    final JsonNode bundle = getBundleData(symbolicName);
    final JsonNode versionNode = bundle.get(JSON_KEY_VERSION);

    if (versionNode == null) {
        throw new ClientException("Cannot get version from bundle json");
    }

    return versionNode.getTextValue();
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-testing-clients,代碼行數:17,代碼來源:OsgiConsoleClient.java

示例5: getBundleState

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
/**
 * Get the state of the bundle
 * @param symbolicName bundle symbolic name
 * @return the state of the bundle
 * @throws ClientException if the state cannot be retrieved
 */
public String getBundleState(String symbolicName) throws ClientException {
    final JsonNode bundle = getBundleData(symbolicName);
    final JsonNode stateNode = bundle.get(JSON_KEY_STATE);

    if (stateNode == null) {
        throw new ClientException("Cannot get state from bundle json");
    }

    return stateNode.getTextValue();
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-testing-clients,代碼行數:17,代碼來源:OsgiConsoleClient.java

示例6: deserialize

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
@Override
public JsonControlJvm deserialize(final JsonParser jp,
                                  final DeserializationContext ctxt) throws IOException {

    final ObjectCodec obj = jp.getCodec();
    final JsonNode rootNode = obj.readTree(jp);
    final JsonNode operation = rootNode.get("controlOperation");

    return new JsonControlJvm(operation.getTextValue());
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:11,代碼來源:JsonControlJvm.java

示例7: deserialize

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
@Override
public JsonControlGroup deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException {

    final ObjectCodec obj = jp.getCodec();
    final JsonNode rootNode = obj.readTree(jp);
    final JsonNode operation = rootNode.get("controlOperation");

    return new JsonControlGroup(operation.getTextValue());
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:11,代碼來源:JsonControlGroup.java

示例8: deserialize

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
@Override
public JsonControlWebServer deserialize(final JsonParser jp,
                                  final DeserializationContext ctxt) throws IOException {

    final ObjectCodec obj = jp.getCodec();
    final JsonNode rootNode = obj.readTree(jp);
    final JsonNode operation = rootNode.get("controlOperation");

    return new JsonControlWebServer(operation.getTextValue());
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:11,代碼來源:JsonControlWebServer.java


注:本文中的org.codehaus.jackson.JsonNode.getTextValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。