Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get data from json.. iam using folling code.. but i don't know how to do it using loop..

What I have tried:

Dim request As HttpWebRequest = DirectCast(WebRequest.Create(Url), HttpWebRequest)
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
Dim o As JObject = JObject.Parse(reader.ReadToEnd)
Posted
Updated 24-Jul-16 23:51pm
Comments
Richard MacCutchan 24-Jul-16 3:09am    
What do you mean "i don't know how to do it using loop"?
Member 12480796 4-Aug-16 5:21am    
how to read both timings from following json format

{
"code": 200,
"status": "OK",
"data": [
{
"timings": {
"Fajr": "05:14 (GMT)",
"Sunrise": "06:45 (GMT)",
"Dhuhr": "12:13 (GMT)",
"Asr": "15:04 (GMT)",
"Sunset": "17:42 (GMT)",
"Maghrib": "17:42 (GMT)",
"Isha": "19:13 (GMT)"
},
"date": {
"readable": "01 Mar 2016",
"timestamp": "1456822861"
}
},
{
"timings": {
"Fajr": "05:11 (GMT)",
"Sunrise": "06:43 (GMT)",
"Dhuhr": "12:13 (GMT)",
"Asr": "15:06 (GMT)",
"Sunset": "17:43 (GMT)",
"Maghrib": "17:43 (GMT)",
"Isha": "19:15 (GMT)"
},
"date": {
"readable": "02 Mar 2016",
"timestamp": "1456909261"
}
},

Member 12480796 4-Aug-16 7:55am    
Hi Richard
iam using
Dim sunrise As String = o("data")("timings")("Sunrise")

but i don't know, how to get all sunrise data
Richard MacCutchan 4-Aug-16 8:26am    
You should check the documentation to see how you can iterate through the JObject.

1st way - stackoverflow post

2nd way - msdn microsoft post



These links will help you to understand what is missing in your code. Read carefully.

Happy Programming:)
 
Share this answer
 
Why didn't you search for articles here on CP? E.g. my article:
Consuming a Json WebService from a C# or VB Application[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900