A paid cart deserialized to Newtonsoft's JSON model. · GitHub
source link: https://gist.github.com/einarwh/bdb9f94dfa797bf0abc861165fa723e6
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Instantly share code, notes, and snippets.
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 paidCartDeserialized = JsonConvert.DeserializeObject(paidCartJsonText);
var firstItemTitleToken = paidCartDeserialized["paidItems"][0]["title"]; var firstItemTitle = ((JValue) firstItemTitleToken).Value; var paymentCurrencyToken = paidCartDeserialized["payment"]["currency"]; var paymentCurrency = ((JValue) paymentCurrencyToken).Value;
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK