Java tutorial
//package com.java2s; //License from project: Open Source License import org.json.JSONObject; import java.lang.reflect.Field; public class Main { public static void autoMappingJsonToObject(JSONObject json, Object obj) { Field[] fields = obj.getClass().getFields(); for (Field field : fields) { if (json.optString(field.getName()) != null) { try { field.set(obj, json.optString(field.getName())); } catch (Exception e) { } } } } }