{
"content": "{\"text\":\"Executing NodeDatasetFileOrDirectoryCSV : 1\",\"id\":1,\"name\":\"CSV\",\"type\":\"text\"}"
}
\
tag is getting appended after everything.
I want to access the type field. But i am not able to even after content.type
because of the \
appended after every element. How to remove this ?
You're response is coming down as a valid JSON object, but the content
property holds a value that is a JSON string, not a JSON object. You can either fix it on your server-side however you are constructing your response, or you can use JSON.parse
to parse the content
JSON string into a full-fledged object in JavaScript after you get your response.
The latter would be something like this:
var response = {"content": "{\"text\":\"Executing NodeDatasetFileOrDirectoryCSV : 1\",\"id\":1,\"name\":\"CSV\",\"type\":\"text\"}" };
response.content = JSON.parse(response.content);
console.log(response.content.type);