All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.archive.format.json.CompoundORJSONPathSpec Maven / Gradle / Ivy

The newest version!
package org.archive.format.json;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONObject;

public class CompoundORJSONPathSpec implements JSONPathSpec {
	ArrayList parts;
	public CompoundORJSONPathSpec(List parts) {
		this.parts = new ArrayList();
		for(JSONPathSpec part : parts) {
			this.parts.add(part);
		}
	}

	public List> extract(JSONObject json) {
		List> matches;
		for(JSONPathSpec spec : parts) {
			matches = spec.extract(json);
			// check if empty:
			if(matches.size() == 1) {
				if(matches.get(0).size() == 1) {
					if(matches.get(0).get(0).length() > 0) {
						return matches;
					}
				}
			}
//			if(matches.size() > 0) {
//				if(matches.get(0).size() > 0) {
//					return matches;
//				}
//			}
		}
		return null;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy