I am using a third party api that expects JSON with keyword names like "key-name".
Using Entity Framework I do the following
var result = _context.data.Select(d => new
{
keyName = x.name
});
return Json(new {result = result});
Is there a way to use the appropriate value without replacing the strings after generation manually?
You can create a new class for json result.
e.g:
public class JsonResult{
[JsonProperty(Name="key-name")]
public string KeyName{get;set;}
}
var result = _context.data.Select(d => new JsonResult
{
KeyName = x.name
});
return Json(new {result = result});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With