Lagom compression - how do we decompress?

Hello folks,

I’ve been using JsonSerializer.compressed quite nicely to compress the large payloads. Just wondering if there is a way we can decompress it at the code level.

For example, we have this inspect API that can look at the state and the events of any persistent entities but when some of the events are compressed, we get the exception when we try to inspect.

Thanks,

Hi @lejoow,

compressed JSON payloads are GZIP byte arrays. When Lagom’s JSON serialiser detects the serialized representation in JSON of the data is bigger than a threshold it runs the bytes through a GZIPOutputStream.- So reading a compressed JSON only needs the reverse operation. See the def decompress() code.

Cheers,

(edit: addendum): to detect if a byte array is gzipped, we check the magic bytes at the beginning of the array.