I want to return Json array like this for jwplayer:
{"file":"example_file.mp4","large.file":"","hd.file":"","image":"http://www.example.com/example_image.jpg"}
but however I can just return array without dot (.) in array attribute names. because my mvc viewmodel can't have . in the varible name.
{"file":"example_file.mp4","largefile":"","hdfile":"","image":"http://www.example.com/example_image.jpg"}
Controller code:
public ActionResult Index(int id)
{
return Json(_ext.GetSrcNow(id), JsonRequestBehavior.AllowGet);
}
Model code:
public SrcViewModel GetSrcNow(int Vid_id)
{
var mv = _ext.Get(p => p.video_id == Vid_id);
if (mv == null) return null;
return new SrcViewModel
{
file = mv.vid_src_mp4,
image = mv.vid_image,
largefile = mv.vid_largesrc_mp4,
hdfile = mv.vid_hdsrc_mp4
};
}
ViewModel code:
public class SrcViewModel
{
public string file { get; set; }
public string image { get; set; }
public string largefile { get; set; }
public string hdfile { get; set; }
}
The above code is working perfect with 'largefile' and 'hdfile' attribute names, but I want it like 'large.file' and 'hd.file'
Please help me solve this issue. Thanks