• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSON serialization.

 
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

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 ?

Thank you.





 
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

c) I would say jackson
 
Claude Moore
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Luan,

first, thanks really for your answer.

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)
isn't lost.




 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic