Hello,

First thing, great work, what you are doing with Jackson. It helped me a 
lot.

My approach was to serialize my data objects possibly without having to 
annotate the classes. Here, I am aware, that i broke probably had to break 
with some design goals of your code.

Maps:
In Jackson, the keys of java.util maps are used as names of an object. In 
combination with key(De)serializers, this is a very smart way to serialize 
a map as most maps only have very simple keys and the outcome is quite 
short.
But in my case, this is a bit of a problem. Most objects cannot be restored 
simply from the outcome of their toString()-method. That's why I changed 
the way, maps look like to something like this:
[{"key":{xxx},"value":{xxx}},{"key":{xxx},"value":{xxx}}]
The outcome is a bit longer, but more stable in terms of more complex keys.

circular dependencies
Here, I simply made something like a global switch to turn on adding id's 
to nearly all objects. Here, I faced another problem, that in certain 
cases, when deserializing, if an object is a back reference or a real 
reference.
A variable of type object could be an Integer or a reference to an already 
deserialized object. To face this problem, I replaced the references with a 
small object:
{
    "intVal" : 12,
    "reference" : {"@ref":12}
}
This solution also makes the outcome a bit longer, but guarantees distinct 
references.
 
Type Information
This is another quite common problem. Here, Jackson also already ships a 
nice solution. I played with it a bit and changed two things:
First, objects only get TypeInformation added, if they are of another type 
than the variable/reference, they belong to.
Second, when deserializing, as first step, I look, if TypeInformation is 
added to the object, and if not, I use the type of the variable/given type.

I probably made some other small, less important changes.

I think, that for most of these changes, it would not make sense to run 
them by default. But perhaps, it would help some people to be able to use 
these things optionally.
I am looking forward to get some feedback.

Best regards,
Georg

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to