I have been researching how to convert JavaScript to JSON and properly escape characters, but I am not having much luck. I need to pass a large JavaScript object in a POST call using Postman, following this structure:
{
"key":"/url/url/es", "value":"{myData}"
}
My data structure is too extensive to paste here, but it includes elements such as single quotes, URLs, objects within arrays, and nested objects. I have tried escaping the single quotes and forward slashes in the URLs, removing line breaks, and even using JSON.stringify()
, but nothing seems to be working.
If anyone has any advice on how to correctly encode this complex JavaScript object for passing in a POST request, I would greatly appreciate it.