parispurchase / json-io

Automatically exported from code.google.com/p/json-io
0 stars 0 forks source link

Abbreviation for package path #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Serialize objects with long package names.

What is the expected output? What do you see instead?
{"@type":"package.is.very.long.and.clutters.result.file.to.my.Foo","property"

What version of the product are you using? On what operating system?
2.0.1

Please provide any additional information below.
Hi,

I'm playing around with your json lib, and thought is the following is possible:
When I look at serializations, I can see that the full @type path is defined 
for every object, like the statement above.

Wouldn't it be better to save some kind of abbreviation for every object type, 
and reuse it again. Cause full qualified package names can get quite long, 
which will result in many redundant entries for serialized content.
For my case the filesize could probably be reduced by over 50% if kind of 
shortcuts to the objects would be used.

Original issue reported on code.google.com by KodyReco...@gmail.com on 15 Feb 2013 at 3:58

GoogleCodeExporter commented 9 years ago
Although it appears as the the package names clutter up the JSON, here are a 
few points to keep in mind.  First, the Strings in the JSON will not take up 
heap memory within the JVM when read.  Secondly, if you are using compression 
in your HTTP transmissions (Content-Encoding: gzip, deflate), there will be 
almost zero difference in the size of the JSON whether the package names are 
reduced or not, as the package names will be replaced during gzip compression 
by a small token anyway.  Try it, try zipping a JSON document with and without 
the package names listed and keyed at the top.  The size of both will be very 
similar once compressed.  Finally, where in the JSON would you store them?  It 
would change the 'shape' of the object graph that was originally intended to be 
placed into JSON format.

Original comment by jdereg@gmail.com on 1 Jun 2013 at 9:05