remove extra objects from string or array while hitting api

45 views Asked by At

I wanna pass whole array to api which expects string. My "education" expects any string like "education" : "ncert" but I wanna pass multiple elements to it. So to pass multiple elements I created an array and passed whole array and got this result from the api response:

"education" : "[\"ncert\", \"hello\", \"bye\", \"cbse\", \"hmmm\"]"

but is there any way to pass contents in this format?:

"education" : "ncert, hello, bye, cbse, hmmm"

I saw a code which uses replace(target: "[", replacement: "") but is there any way I can do this in swift?

0

There are 0 answers