deparam javascript

Solutions on MaxInterview for deparam javascript by the best coders in the world

showing results for - "deparam javascript"
Jonas
03 Sep 2016
1function parseParams(str) {
2    return str.split('&').reduce(function (params, param) {
3        var paramSplit = param.split('=').map(function (value) {
4            return decodeURIComponent(value.replace(/\+/g, ' '));
5        });
6        params[paramSplit[0]] = paramSplit[1];
7        return params;
8    }, {});
9}
Kelly
05 Jan 2021
1function params_unserialize(p){
2var ret = {},
3    seg = p.replace(/^\?/,'').split('&'),
4    len = seg.length, i = 0, s;
5for (;i<len;i++) {
6    if (!seg[i]) { continue; }
7    s = seg[i].split('=');
8    ret[s[0]] = s[1];
9}
10return ret;}