Hello All,
I need a small help and feedback as where I am going wrong with my code and understanding.
I am parsing the following json string
I would like to store "EpochDate, Date, Value, Icon, IconPhrase" 5 times one after the other for 5 days
If I use the above code and if I log(L.Get(i)) I get the following output. I get the same data 5 times. Why is new / different data not being stored in the Array ?
I need a small help and feedback as where I am going wrong with my code and understanding.
I am parsing the following json string
B4X:
Private Sub ParseGetForecastWeather5days(jsonData5days As String)
Dim L As List
L.Initialize
Dim parser As JSONParser
parser.Initialize(jsonData5days)
Dim jRoot As Map = parser.NextObject
Dim Headline As Map = jRoot.Get("Headline")
Dim DailyForecasts As List = jRoot.Get("DailyForecasts")
For Each colDailyForecasts As Map In DailyForecasts
Dim EpochDate As Int = colDailyForecasts.Get("EpochDate")
Dim Date As String = colDailyForecasts.Get("Date")
Dim Temperature As Map = colDailyForecasts.Get("Temperature")
Dim Maximum As Map = Temperature.Get("Maximum")
Dim Value As Double = Maximum.Get("Value")
Dim Day As Map = colDailyForecasts.Get("Day")
Dim Icon As Int = Day.Get("Icon")
Dim IconPhrase As String = Day.Get("IconPhrase") 'description
Main.data1 = Array As String(EpochDate,Date,Value,Icon,IconPhrase,EpochDate,Date,Value,Icon,IconPhrase,EpochDate,Date,Value,Icon,IconPhrase,EpochDate,Date,Value,Icon,IconPhrase,EpochDate,Date,Value,Icon,IconPhrase)
L.AddAll(Main.data1)
For i = 0 To 4
Log(L.Get(i))
Next
Next
Log("....")
End Sub
I would like to store "EpochDate, Date, Value, Icon, IconPhrase" 5 times one after the other for 5 days
If I use the above code and if I log(L.Get(i)) I get the following output. I get the same data 5 times. Why is new / different data not being stored in the Array ?
B4X:
1660626000
2022-08-16T07:00:00+02:00
26.1
17
Partly sunny w/ t-storms
1660626000
2022-08-16T07:00:00+02:00
26.1
17
Partly sunny w/ t-storms
1660626000
2022-08-16T07:00:00+02:00
26.1
17
Partly sunny w/ t-storms
1660626000
2022-08-16T07:00:00+02:00
26.1
17
Partly sunny w/ t-storms
1660626000
2022-08-16T07:00:00+02:00
26.1
17
Partly sunny w/ t-storms
....