Is possible to Deserialize just a fragment of JSON using JavaScriptSerializer? I don’t need all data from JSON, just a section.
The JSON data look like this:
// **** snip ****
{
"response": {
some data
}
},
"forecast": {
"txt_forecast": {
"date": "7:00 AM PST",
"forecastday": [ // <-- section needed
{
some data....
},
.........
{
some data....
}
]
},
"simpleforecast": {
"forecastday": [
more data
]
}
// **** snip ****
This is part I need to parse:
"forecastday": [ // <-- section needed
{
some data....
},
.........
{
some data....
}
]
I tried with forecast object ( fragment of whole data ), but it returns null.
var jsonData = new WebClient().DownloadString(url);
JavaScriptSerializer ser = new JavaScriptSerializer();
forecast_class forecast = ser.Deserialize<forecast_class>(jsonData);
Will something like this work for you