0

I have a requirement for passing a JSON object as a url parameter like this : Eg: example.com/index.html&uielements={"Bookmark":["disable"],"Favourite":["hide"]}

Can I use gzip compression to compress the url parameter `uielements' ?

I know we can achieve this using 3rd party libraries like https://github.com/Sage/jsurl/ and http://pieroxy.net/blog/pages/lz-string/index.html but the requirement is not to use any additional library.

Any leads will be very useful.

Thanks in advance.

Amit
  • 193
  • 1
  • 8
  • standard practise is unique id is in url and that get the data from db on the behalf of that particular id – arslan May 04 '20 at 08:07
  • 2
    Why do you want to use gzip here? Is that part of the requirement? This sounds like an [xy problem](http://xyproblem.info/) –  May 04 '20 at 08:09
  • What do you hope to achive by compression? Since gzip creates raw bytes, you will need to encode the result either by percent-encoding or something like base64, undoing a lot of the compression. – Gereon May 04 '20 at 08:09
  • Also, for trivial content like `{"Bookmark":["disable"],"Favourite":["hide"]}` the gzip output is actually larger than the input. – Gereon May 04 '20 at 08:14
  • It is a requirement for a POC I need to come up with insights about can we do it or not, I am not sure how to compress the url parameter using gzip, I have other 2 implementations ready but for comparison I need to implement this – Amit May 04 '20 at 08:16
  • 1
    Here's the [algorithm](https://tools.ietf.org/html/rfc1951#section-Abstract). Now all you need to do is to implement it in JS. –  May 04 '20 at 08:41

0 Answers0