public Object fillData(JSONObject objJson) throws AppErrorException { if (type == null) return null; Object obj = ObjectUtil.newInstance(type); for (JsonAttribute attr : map.values()) { String key = attr.getKey(); if (!objJson.has(key)) { continue; } try { Object value = objJson.get(key); Class<?> typeChild = attr.getFieldType(); // 复杂结构 if (value instanceof JSONObject) { JsonObjectStruct structChild = JsonObjectStructManager.instance().getJsonObjectStruct(typeChild); Object objValue = structChild.fillData((JSONObject) value); ObjectUtil.setValue(attr.getField(), obj, objValue); // 多项内容 } else if (value instanceof JSONArray) { JSONArray array = (JSONArray) value; ArrayList<Object> list = new ArrayList<Object>(); JsonObjectStruct structChild = JsonObjectStructManager.instance().getJsonObjectStruct(typeChild); for (int i = 0; i < array.length(); i++) { JSONObject objValue = array.getJSONObject(i); if (!objValue.keys().hasNext()) { continue; } list.add(structChild.fillData(objValue)); } ObjectUtil.setValue(attr.getField(), obj, list); // 简单数据类型 } else { ObjectUtil.setValue(attr.getField(), obj, value); } } catch (JSONException e) { throw new AppErrorException(this.getClass(), LogConst.STRING_009, e); } } return obj; }