How to compress a string for sending in a JSON object field

1

Hello,

I'm developing an API in java, which returns a JSON object.

One of the final json fields is long text, of unknown size. The text may or may not contain special characters.

I am sending the raw information in a string. But as the dimension is unknown, I am afraid it will exceed what is acceptable. Any way to compress this information?

Can I send the converted string to a byte array, can any client-side language / platform get the original string?

Text can be the size of a multipage document. Who knows of a whole book ...

Thank you.

    
asked by anonymous 05.02.2018 / 15:31

1 answer

0

I'll assume you're working with a REST service.

I would not worry about compacting the string in the hand.

Instead I would certify that the server supports Content-Encoding so the client can query and receive the data compacted. The vast majority of HTTP communication libraries support unpacking transparently and browsers as well.

    
05.02.2018 / 16:15