I’ve got a string field that is an improperly formatted json object that has leading and ending double quotes. “”
Example: (Dummy Data)
“{“ranger”:{“squadwebsite”:“https://forsesthike.montana.com”,“userAgent”:“Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36”,“requestId”:“97ae0290-6b12-42c1-b091-72d486bbd7f3”}}”
What is the easiest way to trim the beginning and ending " to get n8n to see/format this data set as proper json. When I view it in n8n today it just shows up as a string.
I tried .substr and .replace methods in the function node without any luck.
Hoping this is an easy solve for someone. Appreciate any help.
This was helpful but I am still not getting the intended output. In the UI when I run the slice it removes the first and last brace like the quotes don’t exist but in the response (without) the slice the quotes exist and it doesn’t format the json in the table like expected.
Output in response pane on right when executing node without slice command
[
{
"website_visits":
"{"ranger":{"LoginTo":"https://foresthike.montana.com","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","requestId":"97ae0290-6b12-42c1-b091-72d486bbd7f3"}"
}}
]
Output in right pane when executing with slice command
[
{
"website_visits":
""ranger":{"LoginTo":"https://foresthike.montana.com","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","requestId":"97ae0290-6b12-42c1-b091-72d486bbd7f3""
}}
]
If I remove the two double quotes it comes back as valid json from the (non-slice) output.
" before the ranger brace "{“ranger”
" at the ending brace 72d486bbd7f3"}"
With that said I assumed I had to use a function node because in the n8n UI it doesn’t seem to show the additional quotes but in my response it generates them each time I execute the node and presents the output above. Since it’s not valid json n8n doesn’t parse it correctly and put it into the table.
Hopefully I’m being clear enough. Happy to add more detail.