breezback
asked on
JSON deserialization issue
Hi,
Trying to deserialize this JSON string to a proper object to manipulate later.
[*] Attaching the JSON String
It's urgent :) Somehow it doesn't out, I'm using Newton JsonConverter
currently stuck on Exception:
Expected a JsonObjectContract or JsonDictionaryContract for type 'IKayak.Schemas.Contracts. Forecasts. NearestAre a', got 'Newtonsoft.Json.Serializa tion.JsonO bjectContr act'.
Trying to deserialize this JSON string to a proper object to manipulate later.
[*] Attaching the JSON String
It's urgent :) Somehow it doesn't out, I'm using Newton JsonConverter
var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<JSON>(jsonStr);
public class JSON
{
public Data data { get; set; }
}
public class Data
{
public Request request { get; set; }
public NearestArea nearest_area { get; set; }
public Weather weather { get; set; }
}
public class Weather
{
public string date { get; set; }
public string maxtempC { get; set; }
public string mintempC { get; set; }
public IList<Hourly> hourly { get; set; }
}
public class Hourly
{
public string cloudcover,
humidity,
precipMM,
pressure,
sigHeight_m,
swellDir,
swellHeight_m,
swellPeriod_secs,
tempC,
tempF,
time,
visibility,
waterTemp_C,
waterTemp_F,
weatherCode,
winddir16Point,
winddirDegree,
windspeedKmph,
windspeedMiles;
public WeatherIconUrl weatherIconUrl;
}
public class WeatherIconUrl
{
public string value;
}
public class NearestArea
{
public string distance_miles { get; set; }
public string latitude { get; set; }
public string longitude { get; set; }
}
public class Request
{
public string type { get; set; }
public string query { get; set; }
}
currently stuck on Exception:
Expected a JsonObjectContract or JsonDictionaryContract for type 'IKayak.Schemas.Contracts.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
HTH
Ivo Stoykov