Hello,
I have a Controller in which I create a list and want to return this as JSON.
- public class ItemsController : ApiController
- {
- public IHttpActionResult GetItems(ODataQueryOptions
opts) - {
- //Code for filling list ommited
- Dictionary<string, List
> dic1 = new Dictionary<string, List - dic1.Add("Results", result);
- JavaScriptSerializer js = new JavaScriptSerializer();
- var test = js.Serialize(dic1);
- return Ok(test);
- }
- }
This returns the following JSON:
"{\"Results\":[{\"Id\":\"dc58d488-ab94-4c77-a11d-1cb135f7f2f4\"}]}"
But I would like:
{\"Results\":[{\"Id\":\"dc58d488-ab94-4c77-a11d-1cb135f7f2f4\"}]}, thus minus the most outer quotes.
How can I do that?
Jeroen

Sachin SinghRank #66 · 26.2K reputationPosted Oct 22, 2020, 3:44 AM EDT
Jeroen Everhard109 reputationPosted Oct 22, 2020, 4:02 AM EDT
Mageshwaran RRank #411 · 6.1K reputationPosted Oct 22, 2020, 4:21 AM EDT
Varun SetiaRank #308 · 8.2K reputationPosted Oct 22, 2020, 11:17 PM EDT