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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.