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


Java JSONArray.isEmpty方法代碼示例

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


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

示例1: evaluate

import net.minidev.json.JSONArray; //導入方法依賴的package包/類
/**
 * This method evaluates the jsonpath expression on the supplied
 * node.
 *
 * @param jsonpath The jsonpath expression
 * @param data The json data
 * @return The result, or null if not found (which may be due to an expression error)
 */
public static String evaluate(String jsonpath, Object data) {
    String json = serialize(data);

    // No jsonpath means return serialized form
    if (jsonpath == null || jsonpath.trim().isEmpty()) {
        return json;
    }

    if (json != null) {
        Object result = JsonPath.parse(json).read(jsonpath);
        if (result != null) {
            if (result.getClass() == JSONArray.class) {
                JSONArray arr=(JSONArray)result;
                if (arr.isEmpty()) {
                    result = null;
                } else if (arr.size() == 1) {
                    result = arr.get(0);
                }
            }
            return serialize(result);
        }
    }
    return null;
}
 
開發者ID:hawkular,項目名稱:hawkular-apm,代碼行數:33,代碼來源:JSON.java

示例2: PathLocator

import net.minidev.json.JSONArray; //導入方法依賴的package包/類
public PathLocator(JSONArray pathsToFind) {
	if (pathsToFind == null || pathsToFind.isEmpty()) {
		this.pathsToFind = Collections.emptyList();
	} else {
		this.pathsToFind = new ArrayList<String>();
		for (Object s : pathsToFind) {
			this.pathsToFind.add((String) s);
		}
	}
}
 
開發者ID:netplex,項目名稱:json-smart-v2,代碼行數:11,代碼來源:PathLocator.java

示例3: PathRemover

import net.minidev.json.JSONArray; //導入方法依賴的package包/類
public PathRemover(JSONArray pathsToRemove) {
	if (pathsToRemove == null || pathsToRemove.isEmpty()) {
		this.pathsToRemove = Collections.emptyList();
	} else {
		this.pathsToRemove = new ArrayList<String>();
		for (Object s : pathsToRemove) {
			this.pathsToRemove.add((String) s);
		}
	}
}
 
開發者ID:netplex,項目名稱:json-smart-v2,代碼行數:11,代碼來源:PathRemover.java

示例4: PathReplicator

import net.minidev.json.JSONArray; //導入方法依賴的package包/類
public PathReplicator(JSONArray pathsToCopy) {
	if (pathsToCopy == null || pathsToCopy.isEmpty()) {
		this.pathsToCopy = Collections.emptyList();
	} else {
		this.pathsToCopy = new LinkedList<String>();
		for (Object s : pathsToCopy) {
			this.pathsToCopy.add((String) s);
		}
	}
}
 
開發者ID:netplex,項目名稱:json-smart-v2,代碼行數:11,代碼來源:PathReplicator.java

示例5: PathsRetainer

import net.minidev.json.JSONArray; //導入方法依賴的package包/類
public PathsRetainer(JSONArray pathsToRetain) {
	if (pathsToRetain == null || pathsToRetain.isEmpty()) {
		this.pathsToRetain = Collections.emptyList();
	} else {
		this.pathsToRetain = new LinkedList<String>();
		for (Object s : pathsToRetain) {
			this.pathsToRetain.add((String) s);
		}
	}
}
 
開發者ID:netplex,項目名稱:json-smart-v2,代碼行數:11,代碼來源:PathsRetainer.java

示例6: actualEqualsToExpected

import net.minidev.json.JSONArray; //導入方法依賴的package包/類
@Override
public AssertionReport actualEqualsToExpected(Object result) {
    if(result instanceof JSONArray){

        final JSONArray actualArrayValue = (JSONArray) result;

        if(actualArrayValue.isEmpty()){

            return AssertionReport.createFieldMatchesReport();
        }

        return AssertionReport.createFieldDoesNotMatchReport(path, "[]", result);

    } else {

        return AssertionReport.createFieldDoesNotMatchReport(path, "[]", result);

    }
}
 
開發者ID:authorjapps,項目名稱:zerocode,代碼行數:20,代碼來源:ArrayIsEmptyAsserter.java

示例7: extractFieldInstanceList

import net.minidev.json.JSONArray; //導入方法依賴的package包/類
public static List<? extends XmlFieldInstance> extractFieldInstanceList(Object value, String recordId, String jsonPath) {
	List<EdmFieldInstance> extracted = new ArrayList<>();
	if (value.getClass() == String.class) {
		extracted.add(new EdmFieldInstance((String) value));
	} else if (value.getClass() == JSONArray.class) {
		JSONArray outerArray = (JSONArray) value;
		if (outerArray.isEmpty()) {
			return null;
		}

		for (int i = 0, l = outerArray.size(); i < l; i++) {
			Object outerVal = outerArray.get(i);
			if (outerVal.getClass() == String.class) {
				extracted.add(new EdmFieldInstance((String) outerVal));
			} else if (outerVal.getClass() == Boolean.class) {
				extracted.add(new EdmFieldInstance(Boolean.toString((Boolean)outerVal)));
			} else if (outerVal.getClass() == Double.class) {
				extracted.add(new EdmFieldInstance(Double.toString((Double)outerVal)));
			} else if (outerVal.getClass() == BigDecimal.class) {
				extracted.add(new EdmFieldInstance(((BigDecimal)outerVal).toString()));
			} else if (outerVal.getClass() == JSONArray.class) {
				extracted.addAll(extractInnerArray(outerVal, recordId, jsonPath));
			} else if (outerVal.getClass() == LinkedHashMap.class) {
				extracted.add(hashToFieldInstance(outerVal, recordId, jsonPath));
			} else {
				logger.severe(String.format(
						  "Unhandled outerArray type: %s, %s [record ID: %s, path: %s]",
						  getType(outerVal), outerVal, recordId, jsonPath
				));
			}
		}
	} else if (value.getClass() == LinkedHashMap.class) {
		extracted.add(hashToFieldInstance(value, recordId, jsonPath));
	} else {
		logger.severe(String.format(
				  "Unhandled object type: %s, [record ID: %s, path: %s]",
				  getType(value), recordId, jsonPath
		));
	}
	return extracted;
}
 
開發者ID:pkiraly,項目名稱:metadata-qa-api,代碼行數:42,代碼來源:JsonUtils.java


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