public void extractStagesAndPlans(JSONObject inputObject) throws Exception { // extract stages JSONObject dependency = inputObject.getJSONObject("STAGE DEPENDENCIES"); if (dependency != null && dependency.length() > 0) { // iterate for the first time to get all the names of stages. for (String stageName : JSONObject.getNames(dependency)) { this.stages.put(stageName, new Stage(stageName, this)); } // iterate for the second time to get all the dependency. for (String stageName : JSONObject.getNames(dependency)) { JSONObject dependentStageNames = dependency.getJSONObject(stageName); this.stages.get(stageName).addDependency(dependentStageNames, this.stages); } } // extract stage plans JSONObject stagePlans = inputObject.getJSONObject("STAGE PLANS"); if (stagePlans != null && stagePlans.length() > 0) { for (String stageName : JSONObject.getNames(stagePlans)) { JSONObject stagePlan = stagePlans.getJSONObject(stageName); this.stages.get(stageName).extractVertex(stagePlan); } } }
@Override protected void fromCheckpointJson(JSONObject json) throws JSONException { super.fromCheckpointJson(json); // conditionals below are for backward compatibility with old checkpoints if (json.has("urlsWritten")) { urlsWritten.set(json.getLong("urlsWritten")); } if (json.has("stats")) { HashMap<String, Map<String, Long>> cpStats = new HashMap<String, Map<String, Long>>(); JSONObject jsonStats = json.getJSONObject("stats"); if (JSONObject.getNames(jsonStats) != null) { for (String key1: JSONObject.getNames(jsonStats)) { JSONObject jsonSubstats = jsonStats.getJSONObject(key1); if (!cpStats.containsKey(key1)) { cpStats.put(key1, new HashMap<String, Long>()); } Map<String, Long> substats = cpStats.get(key1); for (String key2: JSONObject.getNames(jsonSubstats)) { long value = jsonSubstats.getLong(key2); substats.put(key2, value); } } addStats(cpStats); } } }
String[] names = JSONObject.getNames(object); if (names.length != 1) { throw new Exception("Expect only one operator in " + object.toString()); Op op = new Op(opName, null, null, parent, children, attrs, attrObj, this, parser); if (JSONObject.getNames(attrObj) != null) { for (String attrName : JSONObject.getNames(attrObj)) { if (attrName.equals("children")) { Object childrenObj = attrObj.get(attrName);
IOException, Exception { if (vertexObject.length() != 0) { for (String key : JSONObject.getNames(vertexObject)) { if (key.equals("Map Operator Tree:")) { extractOp(vertexObject.getJSONArray(key).getJSONObject(0), null); } else if (key.equals("tagToInput:")) { JSONObject tagToInput = vertexObject.getJSONObject(key); for (String tag : JSONObject.getNames(tagToInput)) { this.tagToInput.put(tag, (String) tagToInput.get(tag));
Vertex v = null; if (opObj.length() > 0) { String[] names = JSONObject.getNames(opObj); for (String name : names) { Object o = opObj.get(name); v.extractOpTree(); } else { for (String attrName : JSONObject.getNames(attrObj)) { if (!attrObj.get(attrName).toString().isEmpty()) { attrs.put(attrName, attrObj.get(attrName).toString());
for (String key : JSONObject.getNames(dataObject)) { dataMap.put(key, dataObject.getString(key)); for (String key : JSONObject.getNames(jsonResopnse.getJSONObject("sources"))) { if (jsonResopnse.getJSONObject("sources").getString(key).contains("hentaidude.com")) { return jsonResopnse.getJSONObject("sources").getString(key);
if (opObject.has("input vertices:")) { JSONObject verticeObj = opObject.getJSONObject("input vertices:"); for (String pos : JSONObject.getNames(verticeObj)) { String vertexName = verticeObj.getString(pos); Map<String, String> posToOpId = new LinkedHashMap<>(); if (keys.length() != 0) { for (String key : JSONObject.getNames(keys)) { for (String key : JSONObject.getNames(keys)) { if (!posToOpId.containsKey(key)) { throw new Exception(
JSONObject edges = tez.getJSONObject("Edges:"); for (String to : JSONObject.getNames(edges)) { vertexs.put(to, new Vertex(to, vertices.getJSONObject(to), this, parser)); for (String to : JSONObject.getNames(edges)) { Object o = edges.get(to); Vertex v = vertexs.get(to); for (String vertexName : JSONObject.getNames(vertices)) { vertexs.put(vertexName, new Vertex(vertexName, vertices.getJSONObject(vertexName), this, parser)); String[] names = JSONObject.getNames(object); if (names != null) { for (String name : names) {
if (this.work != null && (this.work.isUserLevelExplain() || this.work.isFormatted())) { if (jsonOut != null && jsonOut.length() > 0) { ((JSONObject) jsonOut.get(JSONObject.getNames(jsonOut)[0])).put("OperatorId:", operator.getOperatorId()); ((JSONObject) jsonOut.get(JSONObject.getNames(jsonOut)[0])).put("outputname:", ((ReduceSinkDesc) operator.getConf()).getOutputName()); JSONObject jsonOut = outputPlan(op, out, extended, jsonOutput, cindent, "", inTest); if (jsonOutput) { ((JSONObject)json.get(JSONObject.getNames(json)[0])).accumulate("children", jsonOut); json.put(header, jsonOut); } else { for(String k: JSONObject.getNames(jsonOut)) { json.put(k, jsonOut.get(k));
if (this.work != null && (this.work.isUserLevelExplain() || this.work.isFormatted())) { if (jsonOut != null && jsonOut.length() > 0) { ((JSONObject) jsonOut.get(JSONObject.getNames(jsonOut)[0])).put("OperatorId:", operator.getOperatorId()); if (!this.work.isUserLevelExplain() .getOutputOperators(); if (outputOperators != null) { ((JSONObject) jsonOut.get(JSONObject.getNames(jsonOut)[0])).put(OUTPUT_OPERATORS, Arrays.toString(outputOperators.toArray())); JSONObject jsonOut = outputPlan(op, out, extended, jsonOutput, cindent); if (jsonOutput) { ((JSONObject)json.get(JSONObject.getNames(json)[0])).accumulate("children", jsonOut); json.put(header, jsonOut); } else { for(String k: JSONObject.getNames(jsonOut)) { json.put(k, jsonOut.get(k));
private static String[] sortedNamesOf(final JSONObject obj) { String[] raw = JSONObject.getNames(obj); if (raw == null) { return null; } Arrays.sort(raw, String.CASE_INSENSITIVE_ORDER); return raw; }
/** * Wrapping the data into json object * * @return JSONObject */ public JSONObject asJsonObject() { final JSONObject full = new JSONObject(fData, JSONObject.getNames(fData)); return full; }
private void addNames(JSONObject json) { for (String name: JSONObject.getNames(json)) { if (!names.contains(name)) { if ("id".equals(name) || "count".equals(name)) names.add(0, name); else names.add(name); } } }
private Map<String,?> toJavaMap(JSONObject jsonMap) throws JSONException { Map<String,Object> map = new HashMap<String,Object>(); for (String key : JSONObject.getNames(jsonMap)) { Object value = jsonMap.get(key); if (value instanceof JSONObject) { map.put(key, toJavaMap((JSONObject) value)); } else { map.put(key, value); } } return map; }
private void storeConsumerInfos(URI gadgetUri, JSONObject oauthConfig) throws JSONException, GadgetException { for (String serviceName : JSONObject.getNames(oauthConfig)) { JSONObject consumerInfo = oauthConfig.getJSONObject(serviceName); storeConsumerInfo(gadgetUri, serviceName, consumerInfo); } }
private Map<String,?> toJavaMap(JSONObject jsonMap) throws JSONException { Map<String,Object> map = new HashMap<String,Object>(); for (String key : JSONObject.getNames(jsonMap)) { Object value = jsonMap.get(key); if (value instanceof JSONObject) { map.put(key, toJavaMap((JSONObject) value)); } else { map.put(key, value); } } return map; }
private Map<String, Object> convertToMap(JSONObject in, Type type) { Map<String, Object> out = new HashMap<String, Object>(in.length(), 1); if(in.length() == 0) return Collections.emptyMap(); for (String name : JSONObject.getNames(in)) { out.put(name, convertToObject(in.opt(name), type)); } return out; }
private static Map<String, Object> jsonToMap(JSONObject json, Expressions expressions, ELContext context) { Map<String, Object> values = new HashMap<String, Object>(json.length(), 1); for (String key : JSONObject.getNames(json)) { Object val = jsonToConfig(json.opt(key), expressions, context); if (val != null) { values.put(key, val); } } return Collections.unmodifiableMap(values); }
public static String[] listarTemas() { JSONObject json = Configuracoes.getInstancia().getArquivo_temas(); JSONObject json_temas = json.getJSONObject("temas"); return JSONObject.getNames(json_temas); }
private static void assertJsonEquals(JSONObject left, JSONObject right) throws JSONException { assertEquals(left.length(), right.length()); for (String key : JSONObject.getNames(left)) { assertEquals(left.get(key), right.get(key)); } }