Situation: I have multiple Web service API calls that deliver object structures. Currently, I declare explicit types to bind those object structures together. F
The simplest solution is using dynamic
code, i.e. C#'s ExpandoObject to wrap your response in the format you expect the API to have
public JsonResult GetSomething(int param)
{
var (speed, distance) = DataLayer.GetData(param);
dynamic resultVM = new ExpandoObject();
resultVM.speed= speed;
resultVM.distance= distance;
return Json(resultVM);
}
The return type of "GetData
" is
(decimal speed, int distance)
This gives a Json response in the way you expect it to