Hi everyone,
I was wondering if anyone has managed to convert a query string to json format.
example from name=john&age=22&class=mca to {“name”:“john”,“age”:“22”,“class”:“mca”}
I found something similar when researching but was never able to make it work see below
function jsonToQueryString(json) {
return ‘?’ +
Object.keys(json).map(function(key) {
return encodeURIComponent(key) + ‘=’ +
encodeURIComponent(json[key]);
}).join(’&’);
}
The idea of my test scenario is the follow
- get request
- verify HTTPS
- convert into JSON format
4.using JsonSlurper/slurper.parseText to store any of the values example name - make name to global variable for next test scenario
I have to convert it to JSON format in order to make the JsonSlurper working to store the values.
Thanks
Boris