string text = TextBox1.Text.ToString();
var regex = new Regex(@"(?<=#)\w+");
var matches = regex.Matches(text);
foreach (Match m in matches)
{
Label1.Text = m.Value;
string tobesearched = m.Value;
string Cname = text.Split(new string[] { tobesearched }, StringSplitOptions.None).Last();
Label2.Text = Cname.TrimStart();
if (m.Value == "weather" && m.Value != null)
{
string url = string.Format("http://api.openweathermap.org/data/2.5/weather?q={0}",Cname);
using (WebClient client = new WebClient())
{
string content = client.DownloadString(url);
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(weatherdata));
using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content)))
{
// deserialize the JSON object using the WeatherData type.
var weatherData = (weatherdata)serializer.ReadObject(ms);
Label3.Text = Convert.ToString(weatherData.coord.lat);
Label4.Text = Convert.ToString(weatherData.coord.lon);
}
}
}
}
Just now i am creating label to get the required data. WHat if i want to create label Dynamically with the data from json
LIKE
lABEL TEXT="iD": LABEL TEXT="800"
something like this
any refrence would be helfull
jSON