There are at least two solutions:
First: based on the idea of Thomas Broyer
public static String toString(EntityProxy entityProxy) { DefaultProxyStore store = new DefaultProxyStore(); Swap.requestFactory.getSerializer(store).serialize(entityProxy); return store.encode(); }
Something like that:
{"V":"211","P":{" 1@2 @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":" test@example.com ","lastReported":1296194777916,"lastLoginOn":1296194777916}}}}
Second: based on AutoBean framework
public static String toJson(EntityProxy entityProxy) { return AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(entityProxy)).getPayload(); }
Which produce a string like
{"emailAddress":" test@example.com ","lastActive":1296194777916,"lastLoginOn":1296194777916,"lastReported":1296194777916}
The second one is what I need - it is more readable in the magazine.
source share