msgpack icon indicating copy to clipboard operation
msgpack copied to clipboard

JSON Size Smaller Than MessagePack Go Implementation

Open marcsantiago opened this issue 2 years ago • 2 comments

When pasting the JSON below into the official message pack site, it shows a significant decrease in size https://msgpack.org/index.html

{"bar":"spam","foo":[{"spam":"ss","size":{"w":320,"h":480},"n":10,"c":1},{"spam":"ss","size":{"w":300,"h":250},"n":5,"c":1},{"spam":"ss","size":{"w":320,"h":50},"n":1,"c":1},{"spam":"v","size":{"w":-1,"h":-1},"n":20}],"l":10,"b":1}

However when using this package it always shows that the generated output is larger than it's JSON counter part. Any reason why?

Is the site applying compression as well?

marcsantiago avatar Oct 27 '23 22:10 marcsantiago

https://go.dev/play/p/w5Ht9lQi-2V

yuhj86 avatar Nov 20 '23 10:11 yuhj86

I assume, there is the type saved in the []byte. When u store it as json, there is no type definition, its loose and will get duck typed while loading. I also assum this will make this implementation faster than a json encoding/decoding.

But thats just an assumption, i did not check the code, nor did i use it till now :D

ToasterKTN avatar Dec 05 '23 11:12 ToasterKTN