* @throws IllegalAccessException
* @throws InstantiationException
*/
private static JSONObject toJsonObject(Object o) throws IllegalAccessException, InstantiationException, JSONException, NoSuchMethodException {
JSONObject m = new JSONObject();
JsonDataAdapter jda;
Class<?> c = o.getClass();
Field[] fields = c.getDeclaredFields();
for (Field f : fields){
if (f.isAnnotationPresent(Ignore.class)) continue;
f.setAccessible(true);
if(!f.isAnnotationPresent(UseDataAdapter.class))
m.put(f.getName(), JsonSerializer.serialize(f.get(o)));
else{
jda = f.getAnnotation(UseDataAdapter.class).value().newInstance();
m.put(f.getName(), jda.toJson(f.get(o)));
}
}
return m;
}