4 ms·
If this is for a public api i would simply enable gzip and call it a day. if this is for internal use you have a few options. although there is automatic way o
by Herostwist 10y ago
If this is for a public api i would simply enable gzip and call it a day.
if this is for internal use you have a few options. although there is automatic way of reusing or referencing objects within json you can construct your own model using references.
One technique i have used in the past for a smaller memory footprint is to have an data array and then reference index positions within it.
e.g.
{
"items": [
{
"foo": 0,
"bar": {
"desc": 1,
"other": 2
}
},
{
"foo": 3,
"bar": {
"desc": 1,
"other": 2
}
},
"data": [
"foo bar",
"some really long data",
"lots more data",
"not foobar",
]
}
If you are free to use alternative serialisation methods i would recommend you look at protocol buffers.
https://developers.google.com/protocol-buffers/ https://developers.google.com/protocol-buffers/