private static void setMethod(JSONObject o,String method) throws JSONException { o.put("_codeMethod",method); for (String key : EwJson.getKeys(o)) if (o.get(key) instanceof JSONObject) setMethod(o.getJSONObject(key),method); } }
private static void setFile(JSONObject o,String file) throws JSONException { o.put("_codeFile",file); for (String key : EwJson.getKeys(o)) if (o.get(key) instanceof JSONObject) setFile(o.getJSONObject(key),file); } private static void setMethod(JSONObject o,String method) throws JSONException
public static JSONArray copyFromObject(JSONObject object) throws JSONException { final JSONArray result = new EwJsonArray(); for (String key : getKeys(object)) result.put(object.get(key)); return result; }
@Override public Object resolve(Context c, Map<String, String[]> parameters, Map<String, InputStream> dataStreams) throws JSONException { JSONObject jo = getObjAsJsonObject(c, parameters, dataStreams); if (jo == null) return null; JSONArray ja = new JSONArray(); for (String s : EwJson.getKeys(jo)) ja.put(s); return ja; }
@Override public Object resolve(Context c, Map<String, String[]> parameters, Map<String, InputStream> dataStreams) throws JSONException { Map<String, String> documents = new HashMap<String, String>(); JSONObject jo = getObjAsJsonObject(c, parameters, dataStreams); for (String key : EwJson.getKeys(jo)) { documents.put(key,jo.get(key).toString()); } return documents; }
@Override public Object resolve(Context c, Map<String, String[]> parameters, Map<String, InputStream> dataStreams) throws JSONException { JSONObject jo = getObjAsJsonObject(c, parameters, dataStreams); JSONObject result = new JSONObject(); if (jo == null) return null; for (String key : EwJson.getKeys(jo)) { parseInto(result,key,jo.get(key)); } return result; }
@Override public Object resolve(Context c, Map<String, String[]> parameters, Map<String, InputStream> dataStreams) throws JSONException { JSONObject jo = getObjAsJsonObject(c, parameters, dataStreams); JSONObject result = new JSONObject(); if (jo == null) return null; for (String key : EwJson.getKeys(jo)) { parseInto(result,key,jo.get(key)); } return result; }
@Override public Object resolve(Context c, Map<String, String[]> parameters, Map<String, InputStream> dataStreams) throws JSONException { JSONObject jo = getObjAsJsonObject(c, parameters, dataStreams); JSONObject result = new JSONObject(); if (jo == null) return null; for (String key : EwJson.getKeys(jo)) { parseInto(result,key,jo.get(key)); } return result; }
private void listCentricAccumulate(Map<String, String[]> parameters, StringBuilder accmData, JSONObject a) throws JSONException { List<String> indexKeys = EwJson.getKeys(a); for (String key : indexKeys) { JSONArray ja = null; ja = a.getJSONArray(key); accmData.append(encodeCsv(key)); for (int i = 0; i < ja.length(); i++) { if (ja.isNull(i)) continue; accmData.append(","); if (ja.get(i) instanceof Number) accmData.append(ja.get(i)); else accmData.append(encodeCsv(ja.get(i).toString())); } accmData.append("\n"); } }
@Override public Object resolve(Context c, Map<String, String[]> parameters, Map<String, InputStream> dataStreams) throws JSONException { final EwMap<String, String[]> newParams = new EwMap<String, String[]>(parameters); JSONObject jo = getAsJsonObject("params", c, parameters, dataStreams); if (jo != null) for (String s : EwJson.getKeys(jo)) newParams.put(s, new String[]{jo.get(s).toString()}); String codeAsString = getObjAsString(c, parameters, dataStreams); Resolvable r = (Resolvable) ResolverFactory.create(new JSONObject(codeAsString)); return r.resolve(c, newParams, dataStreams); }
/** * @method base64ToFile * @param obj {JSONObject} JSON Object holding the Base64 representation of the file. * @param [mimeType] {String} Force the mime type of the resultant files to be this. * @return {InMemoryFile|List<InMemoryFile>} File Object. */ @Override public Object resolve(Context c, Map<String, String[]> parameters, Map<String, InputStream> dataStreams) throws JSONException { JSONObject obj = getObjAsJsonObject(c, parameters, dataStreams); List<InMemoryFile> result = new EwList<InMemoryFile>(); for (String key : EwJson.getKeys(obj)) { InMemoryFile rf = new InMemoryFile(); rf.name = key; rf.data = Base64.decodeBase64(obj.getString(key)); try { rf.mime = optAsString("mimeType", CruncherMimeType.getMimeType(rf, null), c, parameters, dataStreams); } catch (IOException ex) { Logger.getLogger(CruncherBase64ToFile.class.getName()).log(Level.SEVERE, null, ex); } result.add(rf); } if (result.size() == 0) { return null; } if (result.size() == 1) { return result.get(0); } return result; }
ctxObj = new JSONObject(ctxString); context = new HashMap(); for (String s : EwJson.getKeys(ctxObj))
ctxObj = new JSONObject(ctxString); context = new HashMap(); for (String s : EwJson.getKeys(ctxObj))
ctxObj = new JSONObject(ctxString); context = new HashMap(); for (String s : EwJson.getKeys(ctxObj))
ctxObj = new JSONObject(ctxString); context = new HashMap(); for (String s : EwJson.getKeys(ctxObj))
if (obj.get(paragraph) instanceof JSONObject) scoreObj = obj.getJSONObject(paragraph); for (String topic: EwJson.getKeys(scoreObj))
private void accmDataStream(Map<String, InputStream> dataStreamMap, Object o) throws IOException, JSONException { if (o instanceof File) o = new InMemoryFile((File) o); if (o instanceof InMemoryFile) { InMemoryFile imf = (InMemoryFile) o; dataStreamMap.put(imf.name, imf.getInputStream()); } else if (o instanceof JSONArray) { JSONArray ja = (JSONArray) o; for (int i = 0; i < ja.length(); i++) if (!ja.isNull(i)) accmDataStream(dataStreamMap, ja.get(i)); } else if (o instanceof JSONObject) { JSONObject jo = (JSONObject) o; for (String key : EwJson.getKeys(jo)) if (!jo.isNull(key)) accmDataStream(dataStreamMap, jo.get(key)); } }
for (String key : EwJson.getKeys(jo))
for (String key : EwJson.getKeys(source)) wses.add(new Tuple<String, Double>(key, source.getDouble(key))); EwList.sort(wses, new Comparator<Tuple<String, Double>>()
final List<String> keys = EwJson.getKeys(jo); final int index = keyToIndex(key);