Javascript: Query Params to JSON

PHOTO EMBED

Mon Aug 29 2022 19:39:26 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #javascript

var search = 'abc=foo&def=%5Basf%5D&xyz=5';

obj = JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}');
content_copyCOPY