I have a Web Api 2 end point that returns Json containing an array of image urls. The response from it looks like this
{
"Status": 0,
"Message": "Success",
"Images": [
"http://some.image.com/somepath/SomeReport-0.png",
"http://some.image.com/somepath/SomeReport-1.png"
]
}
I would like the json array to return as an array string. How would I need to set up my response in order to accomplish that? I currently set up the array and the response using this method
// response.status and response.message are added before this
response.Images = imagePaths.Select(x => string.Format(urlString, Path.GetFileName(x)));
HttpResponseMessage apiResponse = Request.CreateResponse(HttpStatusCode.OK, response);
purpose for needing the array returned in string format is so I can appended it to an html data-attribute. Right now if I reference the response like so:
listItem.append('<a class="dd-option" data-path="' + response.Images + '" href="#"></a>');
The content inside the attribute looks like
data-attr="http://some.url.com/somepath/ReportStore/image-0.png,http://some.url.com/somepath/ReportStore/image-1.png"
rather than
data-attr="["http://some.url.com/somepath/ReportStore/image-0.png","http://some.url.com/somepath/ReportStore/image-1.png"]"