Skip to main content
deleted 213 characters in body
Source Link
NathanOliver
  • 183.7k
  • 29
  • 324
  • 440

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,'":"') + '"}');

--------------------------------------------------------FOR ENCODING----------------------------------------------------- First do this:

const source = new URLSearchParams(filters).toString();

and append this to your url:

encodeURIComponent(JSON.stringify(source));

--------------------------------------------------------FOR DECODING-----------------------------------------------------

Do this:

var search = location.search.substring(1);
var filters = JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g,'","').replace(/=/g,'":"') + '"}');

Encoding

First do this:

const source = new URLSearchParams(filters).toString();

and append this to your url:

encodeURIComponent(JSON.stringify(source));

Decoding

Do this:

var search = location.search.substring(1);
var filters = JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g,'","').replace(/=/g,'":"') + '"}');
Source Link

--------------------------------------------------------FOR ENCODING----------------------------------------------------- First do this:

const source = new URLSearchParams(filters).toString();

and append this to your url:

encodeURIComponent(JSON.stringify(source));

--------------------------------------------------------FOR DECODING-----------------------------------------------------

Do this:

var search = location.search.substring(1);
var filters = JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g,'","').replace(/=/g,'":"') + '"}');