I am getting the following string in my request body:
params%5Bparam1%5D=543543¶ms%5Bparam2%5D=fdasghdfghdf¶ms%5Btest%5D=yes
How can I translate this to normal JSON?
This is the request body parsed to Lambda Proxy from API gateway.
I am getting the following string in my request body:
params%5Bparam1%5D=543543¶ms%5Bparam2%5D=fdasghdfghdf¶ms%5Btest%5D=yes
How can I translate this to normal JSON?
This is the request body parsed to Lambda Proxy from API gateway.
If you want something quick and dirty in JavaScript (modified from this related answer)
let params = "params%5Bparam1%5D=543543¶ms%5Bparam2%5D=fdasghdfghdf¶ms%5Btest%5D=yes";
let result = JSON.parse('{"' +
decodeURIComponent(params)
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/params\[/g, '')
.replace(/\]=/g, '=')
.replace(/=/g, '":"') +
'"}');
console.log(result);