cborld icon indicating copy to clipboard operation
cborld copied to clipboard

Single item array could be compressed as a single value saving one byte

Open filip26 opened this issue 3 years ago • 0 comments

Hi, just an idea to improve compress ratio. Consider this example:

{
  "@context": {
    "type": "@type"
  }
}
{
  "@context": "...",
  "type": ["type-id1"]
}

the compressed output by this library is:

[{ 0: https...context.jsonld, 101: [type-id1] }]

101 says it's an array, and there is no need to use CBOR array marker array(1). It could be compressed as [{ 0: https...context.jsonld, 101: type-id1 }] saving one byte.

filip26 avatar Jul 27 '22 18:07 filip26