Android Question Help in parsing and saving Json data in List Array

RushilD

Member
Licensed User
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

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
....
 

toby

Well-Known Member
Licensed User
Longtime User
corrected code: line 9 to 15:
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)
       L.Add(Main.data1)
    Next

    For i = 0 To 4
        Log(L.Get(i))
    Next
 
Upvote 0

RushilD

Member
Licensed User
corrected code: line 9 to 15:
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)
       L.Add(Main.data1)
    Next

    For i = 0 To 4
        Log(L.Get(i))
    Next
Toby Hi, I tried this but it does not work ?

I see the following output

B4X:
[Ljava.lang.String;@9438954
[Ljava.lang.String;@9140fd
[Ljava.lang.String;@53f1f2
[Ljava.lang.String;@aa1f043
[Ljava.lang.String;@4f9e6c0
 
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
Dim arr() As String=Array As object(EpochDate,Date,Value,Icon,IconPhrase)
L.Add(arr)
 
Upvote 0

RushilD

Member
Licensed User
I think it is better to use Map instead of String array.

How can I iterate it ? example i have this code.

B4X:
    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
        
        
        Dim data As Map
        data.Initialize
        
        data.Put(1, EpochDate)
        data.Put(2, Date)
        data.Put(3, Value)
        data.Put(4, Icon)
        
    Next
    Log("...



I want

data.Put(1, EpochDate)
data.Put(2, Date)
data.Put(3, Value)
data.Put(4, Icon)

data.Put(5, EpochDate)
data.Put(6, Date)
data.Put(7, Value)
data.Put(8, Icon)

and soo on,. Any ideas ?
 
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
It's much easier with sample data. See my code below
B4X:
    Dim lst As List
    lst.Initialize
    For i=0 To 4
        Dim arr() As Object
        arr=Array As String("A" & i, "B" & i, "C" & i, "D" &i, "F" & i)
        lst.Add(arr)
    Next
    For Each item() As String In lst
        Log(item(0) & ", " & item(1) & ", " & item(2) & ", " & item(3) & ", " & item(4))
    Next

sample output:
A0, B0, C0, D0, F0
A1, B1, C1, D1, F1
A2, B2, C2, D2, F2
A3, B3, C3, D3, F3
A4, B4, C4, D4, F4
 
Upvote 0

RushilD

Member
Licensed User
It's much easier with sample data. See my code below
B4X:
    Dim lst As List
    lst.Initialize
    For i=0 To 4
        Dim arr() As Object
        arr=Array As String("A" & i, "B" & i, "C" & i, "D" &i, "F" & i)
        lst.Add(arr)
    Next
    For Each item() As String In lst
        Log(item(0) & ", " & item(1) & ", " & item(2) & ", " & item(3) & ", " & item(4))
    Next

sample output:
HI Toby,

I tried what you suggested but when I try to access example the 5th located item it get an error.

B4X:
    Dim parser As JSONParser
    parser.Initialize(jsonData5days)
   
    Dim jRoot As Map = parser.NextObject
    Dim Headline As Map = jRoot.Get("Headline")
   
    Dim EffectiveDate As String = Headline.Get("EffectiveDate")
    Dim EffectiveEpochDate As Int = Headline.Get("EffectiveEpochDate")
   
    Dim Severity As Int = Headline.Get("Severity")
    Dim Text As String = Headline.Get("Text") 'Live status
    Dim Category As String = Headline.Get("Category") 'image
   
    Dim EndEpochDate As Int = Headline.Get("EndEpochDate")'Not Used
    Dim EndDate As String = Headline.Get("EndDate") 'Not Used
   
   
    Log(Text)
    Log(Category)
   
    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
       
        'Dim PrecipitationType As String = Day.Get("PrecipitationType")
        'Dim HasPrecipitation As String = Day.Get("HasPrecipitation")
        'Dim PrecipitationIntensity As String = Day.Get("PrecipitationIntensity")
           
        Dim Data() As Object
        Data = 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)
       

        Main.L.Initialize
        'Main.L.AddAll(Data)
       
        For i = 0 To 4
        Main.l.Add(Data)
            Next
    Next



I want to save the following data and then access it by index. As you can see there are 5 groups

B4X:
1660626000
2022-08-16T07:00:00+02:00
26.1
17
Partly sunny w/ t-storms


1660712400
2022-08-17T07:00:00+02:00
26.7
17
Partly sunny w/ t-storms


1660798800
2022-08-18T07:00:00+02:00
21.3
16
Mostly cloudy w/ t-storms


1660885200
2022-08-19T07:00:00+02:00
22.7
4
Intermittent clouds


1660971600
2022-08-20T07:00:00+02:00
21.1
4
Intermittent clouds
 
Upvote 0

RushilD

Member
Licensed User
I think it is better to use Map instead of String array.
Aeric I tried to use the Maps as well


In Main file
B4X:
    Public data1 As Map
    Public m As Int
    m = 1


B4X:
    Dim parser As JSONParser
    parser.Initialize(jsonData5days)
    
    Dim jRoot As Map = parser.NextObject
    Dim Headline As Map = jRoot.Get("Headline")
    
    Dim EffectiveDate As String = Headline.Get("EffectiveDate")
    Dim EffectiveEpochDate As Int = Headline.Get("EffectiveEpochDate")
    
    Dim Severity As Int = Headline.Get("Severity")
    Dim Text As String = Headline.Get("Text") 'Live status
    Dim Category As String = Headline.Get("Category") 'image
    
    Dim EndEpochDate As Int = Headline.Get("EndEpochDate")'Not Used
    Dim EndDate As String = Headline.Get("EndDate") 'Not Used
    
    
    Log(Text)
    Log(Category)
    
    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
        

        Dim Data() As String
        Data = 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)
        
        
        Dim L As List
        L.Initialize
        L.AddAll(Data)
        
        Main.Data1.Initialize
                
        If Main.m <= 25 Then
            For i = 0 To 4
                
                Main.Data1.Put(Main.m, L.Get(i))
                'Main.lbl(Main.m) = Data(i)
                Log(Main.Data1.Get(Main.m))
                Main.m=Main.m+1
            Next
        End If
    Next

What i notices the values are not saved in the keys. Am i missing something ?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I want to ask doesn't the other post already answered/solved your question?

 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
?
Sample Object (number,string,etc.)
B4X:
Public Sub test
    Dim l As List
    l.Initialize
    For i = 0 To 4
        l.Add(Array ("A", i, "C" ))
    Next
    'option 1
    Log("-- option 1 --")
    For Each s() As Object In l
        Log($" ${s(0)} - ${s(1)} - ${s(2)}"$ )
    Next
    Log("-- option 2 --")
    For Each s() As Object In l
        Log($" ${s(0).As(String)} - ${s(1).As(Int)} - ${s(2).As(String)}"$ )
    Next
End Sub

1660649047977.png
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
B4X:
Public Sub test
    Dim l As List
    l.Initialize
    For i = 0 To 4
        Dim t() As Object = Array ("A", i, "C" )
        l.Add(t)
    Next
    'option 1
    Log("-- option 1 --")
    For Each s() As Object In l
        Log($" ${s(0)} - ${s(1)} - ${s(2)}"$ )
    Next
    Log("-- option 2 --")
    For Each s() As Object In l
        Log($" ${s(0).As(String)} - ${s(1).As(Int)} - ${s(2).As(String)}"$ )
    Next
End Sub
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    Dim strJSON As String = GenerateSampleJSON
    Dim Data As List = ProcessJSON(strJSON)
    
    ' Now display the value
    For i = 0 To Data.Size - 1
        Dim Item As Map = Data.Get(i)
        'Log( Item )
        Log(" ")
        Log(" ")
        For Each key In Item.Keys
            Log( Item.Get(key) )
        Next
    Next
End Sub

Private Sub ProcessJSON (JSON As String) As List
    Dim parser As JSONParser
    parser.Initialize(JSON)
  
    Dim jRoot As Map = parser.NextObject
    Dim Headline As Map = jRoot.Get("Headline")
  
    'Dim EffectiveDate As String = Headline.Get("EffectiveDate")
    'Dim EffectiveEpochDate As Int = Headline.Get("EffectiveEpochDate")
  
    'Dim Severity As Int = Headline.Get("Severity")
    Dim Text As String = Headline.Get("Text") 'Live status
    Dim Category As String = Headline.Get("Category") 'image
  
    'Dim EndEpochDate As Int = Headline.Get("EndEpochDate")'Not Used
    'Dim EndDate As String = Headline.Get("EndDate") 'Not Used
  
    Log(Text)
    Log(Category)
  
    Dim DailyForecasts As List = jRoot.Get("DailyForecasts")
  
    Dim List1 As List
    List1.Initialize
  
    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
      
        'Dim PrecipitationType As String = Day.Get("PrecipitationType")
        'Dim HasPrecipitation As String = Day.Get("HasPrecipitation")
        'Dim PrecipitationIntensity As String = Day.Get("PrecipitationIntensity")
          
        'Dim Data() As Object
        'Data = 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)
      
        'Main.L.Initialize
        'Main.L.AddAll(Data)
      
        'For i = 0 To 4
        '    Main.L.Add(Data)
        'Next
        
        Dim Data As Map
        Data.Initialize
        Data.Put("EpochDate", EpochDate)
        Data.Put("Date", Date)
        Data.Put("Value", Value)
        Data.Put("Icon", Icon)
        Data.Put("IconPhrase", IconPhrase)
        
        List1.Add(Data)
    Next
    
    Return List1
End Sub

Private Sub GenerateSampleJSON As String
    Return $"{
    "Headline": {
        "EffectiveDate": "2022-08-15T08:00:00+02:00",
        "EffectiveEpochDate": 1660543200,
        "Severity": 5,
        "Text": "A thunderstorm Monday",
        "Category": "thunderstorm",
        "EndDate": "2022-08-15T20:00:00+02:00",
        "EndEpochDate": 1660586400,
        "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?unit=c&lang=en-us",
        "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?unit=c&lang=en-us"
    },
    "DailyForecasts": [
        {
            "Date": "2022-08-11T07:00:00+02:00",
            "EpochDate": 1660194000,
            "Temperature": {
                "Minimum": {
                    "Value": 16.1,
                    "Unit": "C",
                    "UnitType": 17
                },
                "Maximum": {
                    "Value": 28.1,
                    "Unit": "C",
                    "UnitType": 17
                }
            },
            "Day": {
                "Icon": 2,
                "IconPhrase": "Mostly sunny",
                "HasPrecipitation": false
            },
            "Night": {
                "Icon": 33,
                "IconPhrase": "Clear",
                "HasPrecipitation": false
            },
            "Sources": [
                "AccuWeather"
            ],
            "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=1&unit=c&lang=en-us",
            "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=1&unit=c&lang=en-us"
        },
        {
            "Date": "2022-08-12T07:00:00+02:00",
            "EpochDate": 1660280400,
            "Temperature": {
                "Minimum": {
                    "Value": 17.5,
                    "Unit": "C",
                    "UnitType": 17
                },
                "Maximum": {
                    "Value": 28.3,
                    "Unit": "C",
                    "UnitType": 17
                }
            },
            "Day": {
                "Icon": 1,
                "IconPhrase": "Sunny",
                "HasPrecipitation": false
            },
            "Night": {
                "Icon": 33,
                "IconPhrase": "Clear",
                "HasPrecipitation": false
            },
            "Sources": [
                "AccuWeather"
            ],
            "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=2&unit=c&lang=en-us",
            "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=2&unit=c&lang=en-us"
        },
        {
            "Date": "2022-08-13T07:00:00+02:00",
            "EpochDate": 1660366800,
            "Temperature": {
                "Minimum": {
                    "Value": 18.3,
                    "Unit": "C",
                    "UnitType": 17
                },
                "Maximum": {
                    "Value": 28.1,
                    "Unit": "C",
                    "UnitType": 17
                }
            },
            "Day": {
                "Icon": 2,
                "IconPhrase": "Mostly sunny",
                "HasPrecipitation": false
            },
            "Night": {
                "Icon": 33,
                "IconPhrase": "Clear",
                "HasPrecipitation": false
            },
            "Sources": [
                "AccuWeather"
            ],
            "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=3&unit=c&lang=en-us",
            "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=3&unit=c&lang=en-us"
        },
        {
            "Date": "2022-08-14T07:00:00+02:00",
            "EpochDate": 1660453200,
            "Temperature": {
                "Minimum": {
                    "Value": 19.9,
                    "Unit": "C",
                    "UnitType": 17
                },
                "Maximum": {
                    "Value": 29.3,
                    "Unit": "C",
                    "UnitType": 17
                }
            },
            "Day": {
                "Icon": 3,
                "IconPhrase": "Partly sunny",
                "HasPrecipitation": false
            },
            "Night": {
                "Icon": 36,
                "IconPhrase": "Intermittent clouds",
                "HasPrecipitation": false
            },
            "Sources": [
                "AccuWeather"
            ],
            "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=4&unit=c&lang=en-us",
            "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=4&unit=c&lang=en-us"
        },
        {
            "Date": "2022-08-15T07:00:00+02:00",
            "EpochDate": 1660539600,
            "Temperature": {
                "Minimum": {
                    "Value": 16.6,
                    "Unit": "C",
                    "UnitType": 17
                },
                "Maximum": {
                    "Value": 23.9,
                    "Unit": "C",
                    "UnitType": 17
                }
            },
            "Day": {
                "Icon": 4,
                "IconPhrase": "Intermittent clouds",
                "HasPrecipitation": true,
                "PrecipitationType": "Rain",
                "PrecipitationIntensity": "Moderate"
            },
            "Night": {
                "Icon": 35,
                "IconPhrase": "Partly cloudy",
                "HasPrecipitation": false
            },
            "Sources": [
                "AccuWeather"
            ],
            "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=5&unit=c&lang=en-us",
            "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=5&unit=c&lang=en-us"
        }
    ]
}"$
End Sub
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
?
B4X:
Public Sub TestJson4
 
    Dim jRoot As Map = GetTextJSON.As(JSON).ToMap

'    Dim EffectiveDate As String     = jRoot.Get("Headline").As(Map).Get("EffectiveDate")
'    Dim EffectiveEpochDate As Int     = jRoot.Get("Headline").As(Map).Get("EffectiveEpochDate")
'    Dim Severity As Int             = jRoot.Get("Headline").As(Map).Get("Severity")
'    Dim text As String                 = jRoot.Get("Headline").As(Map).Get("Text") 'Live status
'    Dim Category As String             = jRoot.Get("Headline").As(Map).Get("Category") 'image
'    Dim EndEpochDate As Int         = jRoot.Get("Headline").As(Map).Get("EndEpochDate")'Not Used
'    Dim EndDate As String             = jRoot.Get("Headline").As(Map).Get("EndDate") 'Not Used
 
 
    Dim DailyForecasts As List = jRoot.Get("DailyForecasts")
 
    Dim List1, List2 As List
    List1.Initialize
    List2.Initialize
 
    For Each colDailyForecasts As Map In DailyForecasts
      
        Dim Data1 As Map = CreateMap("EpochDate"      : colDailyForecasts.Get("EpochDate"), _
                                     "Date"          : colDailyForecasts.Get("Date"), _
                                     "Value"         : colDailyForecasts.Get("Temperature").As(Map).Get("Minimum").As(Map).Get("Value"), _
                                     "Icon"              : colDailyForecasts.Get("Day").As(Map).Get("Icon"), _
                                     "IconPhrase"    : colDailyForecasts.Get("Day").As(Map).Get("IconPhrase"))
        List1.Add(Data1)
                                    
        Dim Data2() As Object = Array (colDailyForecasts.Get("EpochDate"), _
                                      colDailyForecasts.Get("Date"), _
                                      colDailyForecasts.Get("Temperature").As(Map).Get("Minimum").As(Map).Get("Value"), _
                                      colDailyForecasts.Get("Day").As(Map).Get("Icon"), _
                                      colDailyForecasts.Get("Day").As(Map).Get("IconPhrase"))
                                    
        List2.Add(Data2)
    Next
    
'    option 1
    Log("--- option 1 (MAP) ---")
    For Each s1 As Map In List1
        Log($"${s1.Get("EpochDate")} - ${s1.Get("Date")} - ${s1.Get("Value")} - ${s1.Get("Icon")} - ${s1.Get("IconPhrase")}"$)
    Next
    
'    option 2
    Log("--- option 2 (ARRAY) ---")
    For Each s2() As Object In List2
        Log($"${s2(0)} - ${s2(1)} - ${s2(2)} - ${s2(3)} - ${s2(4)}"$)
    Next
End Sub

Public Sub GetTextJSON As String
    Return $"
{
  "Headline": {
    "EffectiveDate": "2022-08-15T08:00:00+02:00",
    "EffectiveEpochDate": 1660543200,
    "Severity": 5,
    "Text": "A thunderstorm Monday",
    "Category": "thunderstorm",
    "EndDate": "2022-08-15T20:00:00+02:00",
    "EndEpochDate": 1660586400,
    "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?unit=c&lang=en-us",
    "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?unit=c&lang=en-us"
  },
  "DailyForecasts": [
    {
      "Date": "2022-08-11T07:00:00+02:00",
      "EpochDate": 1660194000,
      "Temperature": {
        "Minimum": {
          "Value": 16.1,
          "Unit": "C",
          "UnitType": 17
        },
        "Maximum": {
          "Value": 28.1,
          "Unit": "C",
          "UnitType": 17
        }
      },
      "Day": {
        "Icon": 2,
        "IconPhrase": "Mostly sunny",
        "HasPrecipitation": false
      },
      "Night": {
        "Icon": 33,
        "IconPhrase": "Clear",
        "HasPrecipitation": false
      },
      "Sources": [
        "AccuWeather"
      ],
      "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=1&unit=c&lang=en-us",
      "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=1&unit=c&lang=en-us"
    },
    {
      "Date": "2022-08-12T07:00:00+02:00",
      "EpochDate": 1660280400,
      "Temperature": {
        "Minimum": {
          "Value": 17.5,
          "Unit": "C",
          "UnitType": 17
        },
        "Maximum": {
          "Value": 28.3,
          "Unit": "C",
          "UnitType": 17
        }
      },
      "Day": {
        "Icon": 1,
        "IconPhrase": "Sunny",
        "HasPrecipitation": false
      },
      "Night": {
        "Icon": 33,
        "IconPhrase": "Clear",
        "HasPrecipitation": false
      },
      "Sources": [
        "AccuWeather"
      ],
      "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=2&unit=c&lang=en-us",
      "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=2&unit=c&lang=en-us"
    },
    {
      "Date": "2022-08-13T07:00:00+02:00",
      "EpochDate": 1660366800,
      "Temperature": {
        "Minimum": {
          "Value": 18.3,
          "Unit": "C",
          "UnitType": 17
        },
        "Maximum": {
          "Value": 28.1,
          "Unit": "C",
          "UnitType": 17
        }
      },
      "Day": {
        "Icon": 2,
        "IconPhrase": "Mostly sunny",
        "HasPrecipitation": false
      },
      "Night": {
        "Icon": 33,
        "IconPhrase": "Clear",
        "HasPrecipitation": false
      },
      "Sources": [
        "AccuWeather"
      ],
      "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=3&unit=c&lang=en-us",
      "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=3&unit=c&lang=en-us"
    },
    {
      "Date": "2022-08-14T07:00:00+02:00",
      "EpochDate": 1660453200,
      "Temperature": {
        "Minimum": {
          "Value": 19.9,
          "Unit": "C",
          "UnitType": 17
        },
        "Maximum": {
          "Value": 29.3,
          "Unit": "C",
          "UnitType": 17
        }
      },
      "Day": {
        "Icon": 3,
        "IconPhrase": "Partly sunny",
        "HasPrecipitation": false
      },
      "Night": {
        "Icon": 36,
        "IconPhrase": "Intermittent clouds",
        "HasPrecipitation": false
      },
      "Sources": [
        "AccuWeather"
      ],
      "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=4&unit=c&lang=en-us",
      "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=4&unit=c&lang=en-us"
    },
    {
      "Date": "2022-08-15T07:00:00+02:00",
      "EpochDate": 1660539600,
      "Temperature": {
        "Minimum": {
          "Value": 16.6,
          "Unit": "C",
          "UnitType": 17
        },
        "Maximum": {
          "Value": 23.9,
          "Unit": "C",
          "UnitType": 17
        }
      },
      "Day": {
        "Icon": 4,
        "IconPhrase": "Intermittent clouds",
        "HasPrecipitation": true,
        "PrecipitationType": "Rain",
        "PrecipitationIntensity": "Moderate"
      },
      "Night": {
        "Icon": 35,
        "IconPhrase": "Partly cloudy",
        "HasPrecipitation": false
      },
      "Sources": [
        "AccuWeather"
      ],
      "MobileLink": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=5&unit=c&lang=en-us",
      "Link": "http://www.accuweather.com/en/de/hemer/58675/daily-weather-forecast/174476?day=5&unit=c&lang=en-us"
    }
  ]
}   
"$
End Sub
1660654641589.png
 
Upvote 0
Top