至少有2種解決方案:
第一:基於這樣的理念通過Thomas Broyer
public static String toString(EntityProxy entityProxy)
{
DefaultProxyStore store = new DefaultProxyStore();
Swap.requestFactory.getSerializer(store).serialize(entityProxy);
return store.encode();
}
即產生這樣的:
{"V":"211","P":{"[email protected]@biz.daich.swap.shared.dto.UserAccountProxy":{"O":"PERSIST","R":"2","Y":1,"T":"biz.daich.swap.shared.dto.UserAccountProxy","P":{"id":null,"items":null,"channelId":null,"lastActive":1296194777916,"name":null,"emailAddress":"[email protected]","lastReported":1296194777916,"lastLoginOn":1296194777916}}}}
二:基於AutoBean framework
public static String toJson(EntityProxy entityProxy)
{
return AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(entityProxy)).getPayload();
}
即產生串狀
{"emailAddress":"[email protected]","lastActive":1296194777916,"lastLoginOn":1296194777916,"lastReported":1296194777916}
第二正是我所需要的 - 它在日誌的可讀性。
謝謝,我發現你的想法下的問題的2個答案! – 2011-01-30 16:55:33