I have a couple of questions about JSON serialization of Java objects.
a) I wonder if JSON serialization may or not be a valid replacement for Java standard serialization even when used in a very general way, I mean: even when one's going to
serialize and deserialize an arbitrary complex object, and you can't or you don't won't to use special annotations on class you're going to serialize/deserialize.
b) Would be - generally speaking - JSOn serialization faster and/or a better performer than Java default serialization with respect to bandwidth usage ?
c) If you needed maxim control over JSon serialization mechanism, which library would you suggest to use ?
a) You might get some problem with Generic Types. There are other problems (some I will mention answering the next questions but others I don't remember right now) I didn't understood the second part of this question about the annotations and other things.
b) Java serialization will turn the content into binary and compress it using zip. So it is much smaller (the bigger the object, the bigger would be the different size of the JSON and Java serialization). About which one is faster, I would say if you consider both in memory, probably the time is almost the same, maybe a bit more time in the Java serialization due the compression algorithm but maybe not due the necessary processing for JSON serialization. Also if you consider to persit it or to send over the entwork, the Java serialization would be faster.
About question a), I try and be clearer... With Java serialization, you have an out-of-the-box mechanism to marshal any kind of object, no matter how complex it may be. I've seen that under certain circumstances
you may need to use specific JSON-library annotations to take control over "serialization" mechanism.. I have in mind,for example, just Jackson library you suggest me as a viable option.
About data size after serialization, well, compression is not specific or built in with Java serialization... you may compress Jackson data as well, so the problem would be: which type of serialization as
the minimal representation payload ? XML is known to be very verbose; JSON is by far more concise than XML.... I'd like to have a general framework for serialization where information about typing (for example)
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com