Flattening an object graph to a map
<p>I'm trying to flatten an object graph completely to a map.</p>

<p>Complex objects should also be flattened to the top level using "namespaces". So if the object A contains an int i, a string pid and another object B that contains a string id, the resulting Map would look like {i=1, pid="test", B.id="test1"}. </p>

<p>I also want to be able to reconstruct the original object from a given map. </p>

<p>I've searched around for libraries that do this. But I'm not quite getting what I'm looking for. I see stuff that maintains the hierarchy but nothing that completely flattens the structure. </p>

<p>I do see something in Spring Integration that looks like what I want to do: 
<a href="http://static.springsource.org/spring-integration/api/org/springframework/integration/transformer/ObjectToMapTransformer.html#ObjectToMapTransformer%28%29" rel="nofollow">http://static.springsource.org/spring-integration/api/org/springframework/integration/transformer/ObjectToMapTransformer.html#ObjectToMapTransformer%28%29</a></p>

<p>But I can't get it to work. </p>

<p>Any help would be appreciated.</p>

<p>Thanks.</p>
