Skip to content

Instantly share code, notes, and snippets.

@jskeet
Created March 26, 2018 07:10
Show Gist options
  • Save jskeet/e04a01d5f2b94f478dc2e874de7240f7 to your computer and use it in GitHub Desktop.
Save jskeet/e04a01d5f2b94f478dc2e874de7240f7 to your computer and use it in GitHub Desktop.
using System;
using Newtonsoft.Json;
public class MainModel
{
[JsonProperty(PropertyName = "pageTitle")]
public string PageTitle { get; set; }
[JsonProperty(PropertyName = "helpBtnText")]
public string HelpButtonText { get; set; }
[JsonProperty(PropertyName = "nestedModel")]
public NestedViewModel NestedViewModel { get; set; }
}
public class NestedViewModel
{
[JsonProperty(PropertyName = "headerText")]
public string HelpButtonText { get; set; }
[JsonProperty(PropertyName = "submitBtnText")]
public string SubmitButtonText { get; set; }
}
public static class Program
{
static void Main()
{
var model = new MainModel
{
PageTitle = "page title",
HelpButtonText = "help button text",
NestedViewModel = new NestedViewModel
{
HelpButtonText = "nested help",
SubmitButtonText = "nested submit"
}
};
Console.WriteLine(JsonConvert.SerializeObject(model));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment