Encoding
--------------------------------------------------------FOR ENCODING----------------------------------------------------- First First do this:
const source = new URLSearchParams(filters).toString();
and append this to your url:
encodeURIComponent(JSON.stringify(source));
--------------------------------------------------------FOR DECODING-----------------------------------------------------
Decoding
Do this:
var search = location.search.substring(1);
var filters = JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g,'","').replace(/=/g,'":"') + '"}');