use of org.acra.collector.CrashReportData in project acra by ACRA.
the class JsonUtils method toCrashReportData.
public static CrashReportData toCrashReportData(JSONObject json) {
CrashReportData data = new CrashReportData();
for (Iterator<String> iterator = json.keys(); iterator.hasNext(); ) {
String key = iterator.next();
try {
ReportField field = ReportField.valueOf(key);
Object value = json.get(key);
if (value instanceof JSONObject) {
data.put(field, new ComplexElement((JSONObject) value));
} else if (value instanceof Number) {
data.putNumber(field, (Number) value);
} else if (value instanceof Boolean) {
data.putBoolean(field, (Boolean) value);
} else {
data.putString(field, value.toString());
}
} catch (IllegalArgumentException e) {
Log.w(LOG_TAG, "Unknown report key " + key, e);
} catch (JSONException e) {
Log.w(LOG_TAG, "Unable to read report field " + key, e);
}
}
return data;
}
Aggregations