private List<AeNoticeListVO> getListVo(Object info,String storeId,String storeName) throws Exception
{
List<AeNoticeListVO> rL = new ArrayList<AeNoticeListVO>();
JSONArray aInfo = (JSONArray)info;
if(aInfo.size()==0)
{
return rL;
}
for (int i = 0; i < aInfo.size(); i++)
{
JSONObject jItem = aInfo.getJSONObject(i);
AeNoticeListVO aevo = new AeNoticeListVO();
Field[] field = aevo.getClass().getDeclaredFields();
for(int j=0;j<field.length;j++)
{
String value = getJasonValue(jItem,field[j].getName());
if(null!=value)
{
Method m = aevo.getClass().getMethod("set"+captureName(field[j].getName()),String.class);
m.invoke(aevo, value);
}
}
aevo.setStore_id(storeId);
aevo.setStore_name(storeName);
aevo.setUpdate_time(new Date());
rL.add(aevo);
}
return rL;
}
注意自動的set的方法第一個字母都是大寫
protected String captureName(String name) {
char[] cs=name.toCharArray();
cs[0]-=32;
return String.valueOf(cs);
}