using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace HelloWorldMvcApp
public class SampleViewModel : AsSerializeable
public string Name { get; set; }
public List<NestedData> NestedData { get; set; }
this.Name = "Serialization Demo";
this.NestedData = Enumerable.Range(0,10).Select(i => new NestedData(i)).ToList();
public int Id { get; set; }
public NestedData(int id)
public abstract class AsSerializeable
return JsonConvert.SerializeObject(this);