KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm really stuck on this problem now for 2 days, how can I get the data out of a deeply nested json object. I have found an online json tools http://www.jsoneditoronline.org/ http://jsonformat.com/ which when you paste your json into it, shows all the objects arrays etc, so I can dig down into the data and get the information I want. When I debug the code and put a break point on: foreach (JToken data in rates.ToArray()) I can see the data I'm after, I just cannot get the data out, depends on what I try depends on the error I get, last error was. Error converting value "@rateChange" to type 'Web.UI.Controllers.HomeController+RateInfo'. Could not cast or convert from System.String to Web.UI.Controllers.HomeController+RateInfo. Any help with this is much appreciated. My class public class RateInfo { public string RateChange { get; set; } public string Promo { get; set; } public string PriceBreakdown { get; set; } public bool NonRefundable { get; set; } public string RateType { get; set; } public int CurrentAllotment { get; set; } public int? PromoId { get; set; } public string PromoDescription { get; set; } public string PromoType { get; set; } } code IList<JToken> rates = root["HotelListResponse"]["HotelList"]["HotelSummary"][0]["RoomRateDetailsList"]["RoomRateDetails"]["RateInfos"]["RateInfo"].Children().ToList(); IList<RateInfo> info = new List<RateInfo>(); foreach (JToken data in rates.ToArray()) { RateInfo rateInfo = JsonConvert.DeserializeObject<RateInfo
Tags (comma-separated)
Save Edits
Cancel