Exemple #1
0
static ConstValue sliceKey(const ConstValue &key, natural groupLevel, const Json &json) {
	if (key->isArray()) {
		if (key.length() <= groupLevel) return key;
		Container out = json.array();
		for (natural i = 0; i < groupLevel; i++)
			out.add(key[i]);
		return out;
	} else {
		return key;
	}

}
Exemple #2
0
static bool canGroupKeys(const ConstValue &subj, const ConstValue &sliced) {
	if (sliced == null) return false;
	if (subj->isArray()) {
		natural cnt = subj.length();
		if (cnt >= sliced.length()) {
			cnt = sliced.length();
		} else {
			return false;
		}

		for (natural i = 0; i < cnt; i++) {
			if (compareJson(subj[i],sliced[i]) != cmpResultEqual) return false;
		}
		return true;
	} else {
		return compareJson(subj,sliced) == cmpResultEqual;
	}
}