Skip to content

Instantly share code, notes, and snippets.

@einarwh
Last active May 13, 2020 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/8d884bb611e29006be0ea810926225f7 to your computer and use it in GitHub Desktop.
Save einarwh/8d884bb611e29006be0ea810926225f7 to your computer and use it in GitHub Desktop.
Deserialization of a paid cart.
var paidCartJsonString = @"{
""_state"": ""paid"",
""paidItems"": [
{
""id"": ""1bcd"",
""title"": ""gizmo""
},
{
""id"" : ""3cdf"",
""title"": ""widget"",
""description"": ""A very useful item""
}
],
""payment"": {
""amount"": 123.5,
""currency"": ""USD""
},
""timestamp"": ""2020-04-11T10:11:33.514+02:00""
}";
var paidCartDtoFromText = JsonConvert.DeserializeObject<PaidCart>(paidCartJsonString);
var firstItemTitle = paidCartDtoFromText.PaidItems[0].Title;
var currency = paidCartDtoFromText.Payment.Currency;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment