次のようなモデルがあります。
public class GridViewModel
{
public List<List<KeyValuePair<string, string>>> Rows { get; set; }
public int FoundItems { get; set; }
public int CurrentPage { get; set; }
public int TotalPages { get; set; }
public int ItemsPerPage { get; set; }
public string PagingLinks { get; set; }//Contains Html Tags
}
Rows
次のようにコントローラーに動的に入力します。
Rows = [ [Id=1, Name='Name', FullName='FullName'], [Id=2, Name='Name', FullName='FullName'], ... ];
JsonResult を介して送信するために、モデルを JSON に変換したいと考えています。
だから、私は JSON で次のようなものを期待しています:
{
Rows : [
{ Id=1, Name='Name', FullName='FullName'},
{ Id=2, Name='Name', FullName='FullName'}
],
FoundItems : 123,
CurrentPage : 1,
TotalPages : 3,
ItemsPerPage : 50,
PagingLinks : '<b>1</b><span>2</span><span>3</span>'
}
どうすればモデルを JSON に変換できますか?