com.amazonaws.util.json.JSONArray Java Examples

The following examples show how to use com.amazonaws.util.json.JSONArray. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaStorageProcessor.java    From wt1 with Apache License 2.0 6 votes vote down vote up
private JSONObject decodeParams(String params) {
    Map<String, String[]> eparams =  Utils.decodeQueryString(params);
    JSONObject paramsObj = new JSONObject();
    for (String key : eparams.keySet()) {
        String[] vals = eparams.get(key);
        if (vals.length == 1) {
            try {
                paramsObj.put(key, Long.parseLong(vals[0]));   
            } catch (NumberFormatException e) {
                try {
                    paramsObj.put(key, Double.parseDouble(vals[0]));
                } catch (NumberFormatException e2) {
                    paramsObj.put(key, vals[0]);
                }
            }
        } else{
            JSONArray arr = new JSONArray();
            for (String s : vals) arr.put(s);
            paramsObj.put(key, arr);
        }
    }
    return paramsObj;
}
 
Example #2
Source File: ApiGatewaySdkRamlApiImporter.java    From aws-apigateway-importer with Apache License 2.0 5 votes vote down vote up
private List<String> jsonObjectToListString (JSONArray json) {
    if (json == null) {
      return null;
    }

    final List<String> list = new ArrayList<>();

    for (int i = 0; i < json.length(); i++) {
        try {
            list.add(json.getString(i));
        } catch (JSONException e) {}
    }

    return list;
}