Created
March 26, 2018 07:10
-
-
Save jskeet/e04a01d5f2b94f478dc2e874de7240f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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