Package lesson6.test

Examples of lesson6.test.Cat


     * @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;
    }
View Full Code Here

TOP

Related Classes of lesson6.test.Cat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.