use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class JSONs method requiredString.
/**
* Read an expected string.
*
* @param o the object to parse
* @param id the key in the map that points to the string
* @return the string
* @throws JSONConverterException if the key does not point to a string
*/
public static String requiredString(JSONObject o, String id) throws JSONConverterException {
checkKeys(o, id);
Object x = o.get(id);
return x.toString();
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class JSONs method requiredNodePart.
/**
* Read partitions of nodes.
*
* @param mo the associated model to browse
* @param o the object to parse
* @param id the key in the map that points to the partitions
* @return the parsed partition
* @throws JSONConverterException if the key does not point to partitions of nodes
*/
public static Set<Collection<Node>> requiredNodePart(Model mo, JSONObject o, String id) throws JSONConverterException {
Set<Collection<Node>> nodes = new HashSet<>();
Object x = o.get(id);
if (!(x instanceof JSONArray)) {
throw new JSONConverterException("Set of identifiers sets expected at key '" + id + "'");
}
for (Object obj : (JSONArray) x) {
nodes.add(nodesFromJSON(mo, (JSONArray) obj));
}
return nodes;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class InstanceConverter method toJSON.
@Override
public JSONObject toJSON(Instance instance) throws JSONConverterException {
JSONObject ob = new JSONObject();
ob.put(MODEL_LABEL, moc.toJSON(instance.getModel()));
ob.put(CONSTRAINTS_LABEL, cc.toJSON(instance.getSatConstraints()));
ob.put(OBJ_LABEL, cc.toJSON(instance.getOptConstraint()));
return ob;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class KilledConverter method toJSON.
@Override
public JSONObject toJSON(Killed o) {
JSONObject c = new JSONObject();
c.put("id", getJSONId());
c.put("vm", JSONs.elementToJSON(o.getInvolvedVMs().iterator().next()));
return c;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class MinMigrationsConverter method toJSON.
@Override
public JSONObject toJSON(MinMigrations o) {
JSONObject c = new JSONObject();
c.put("id", getJSONId());
return c;
}
Aggregations