1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| JsonConfig config = new JsonConfig(); config.setPropertySetStrategy(new PropertySetStrategy() { @Override public void setProperty(Object bean, String key, Object value) throws JSONException { try { PropertyUtils.setNestedProperty(bean, key, value); } catch (Exception e) { e.printStackTrace(); } } }); XXBean xx = new XXBean(); XXBeanPK pk = new XXBeanPK(); xx.setPk(pk);
JSONUtils.getMorpherRegistry().registerMorpher( new DateMorpher(new String[] { "dd/MM/yyyy", "HH:mm" }));
xx = (XX) JSONObject.toBean(JSONObject.fromObject(data, config), xx, config); log.info("xx "+ ToStringBuilder.reflectionToString(xx, ToStringStyle.MULTI_LINE_STYLE));
|