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


Java JsonNode.getElements方法代碼示例

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


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

示例1: flatMap

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
@Override
public void flatMap(String tweetJsonStr, Collector<Tuple2<String, Integer>> collector) throws Exception {
    JsonNode tweetJson = mapper.readTree(tweetJsonStr);
    JsonNode entities = tweetJson.get("entities");
    if (entities == null) return;

    JsonNode hashtags = entities.get("hashtags");
    if (hashtags == null) return;

    for (Iterator<JsonNode> iter = hashtags.getElements(); iter.hasNext();) {
        JsonNode node = iter.next();
        String hashtag = node.get("text").getTextValue();

        if (hashtag.matches("\\w+")) {
            collector.collect(new Tuple2<>(hashtag, 1));
        }
    }
}
 
開發者ID:mushketyk,項目名稱:flink-examples,代碼行數:19,代碼來源:TopTweet.java

示例2: deserialize

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
@Override
public List<Rule> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
	ObjectCodec oc = jp.getCodec();
       JsonNode jsonNode = oc.readTree(jp);
       Iterator<JsonNode> childrenNodesIter=jsonNode.getElements();
       List<Rule> rules=new ArrayList<Rule>();
       while(childrenNodesIter.hasNext()){
       	JsonNode childNode=childrenNodesIter.next();
       	rules.add(parseRule(jp,childNode));
       }
	return rules;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:13,代碼來源:RuleJsonDeserializer.java

示例3: getProperties

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
/**
 * @return the bundle properties in a {@link Map}
 */
public Map<String, String> getProperties() {
    JsonNode props = bundle.get("props");
    Map<String, String> entries = new HashMap<String, String>();

    if(props != null) {
        Iterator<JsonNode> it = props.getElements();
        while(it.hasNext()) {
            JsonNode n = it.next();
            entries.put(n.get("key").getTextValue(), n.get("value").getTextValue());
        }
    }
    return entries;
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-testing-clients,代碼行數:17,代碼來源:BundleInfo.java

示例4: getConfiguration

import org.codehaus.jackson.JsonNode; //導入方法依賴的package包/類
/**
 * Returns a map of all properties set for the config referenced by the PID, where the map keys
 * are the property names.
 *
 * @param pid the pid of the configuration
 * @param expectedStatus list of accepted statuses of the response
 * @return the properties as a map
 * @throws ClientException if the response status does not match any of the expectedStatus
 */
public Map<String, Object> getConfiguration(String pid, int... expectedStatus) throws ClientException {
    // make the request
    SlingHttpResponse resp = this.doPost(URL_CONFIGURATION + "/" + pid, null);
    // check the returned status
    HttpUtils.verifyHttpStatus(resp, HttpUtils.getExpectedStatus(SC_OK, expectedStatus));
    // get the JSON node
    JsonNode rootNode = JsonUtils.getJsonNodeFromString(resp.getContent());
    // go through the params
    Map<String, Object> props = new HashMap<String, Object>();
    if(rootNode.get("properties") == null)
        return props;
    JsonNode properties = rootNode.get("properties");
    for(Iterator<String> it = properties.getFieldNames(); it.hasNext();) {
        String propName = it.next();
        JsonNode value = properties.get(propName).get("value");
        if(value != null) {
            props.put(propName, value.getValueAsText());
            continue;
        }
        value = properties.get(propName).get("values");
        if(value != null) {
            Iterator<JsonNode> iter = value.getElements();
            List<String> list = new ArrayList<String>();
            while(iter.hasNext()) {
                list.add(iter.next().getValueAsText());
            }
            props.put(propName, list.toArray(new String[list.size()]));
        }
    }
    return props;
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-testing-clients,代碼行數:41,代碼來源:OsgiConsoleClient.java


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