Android Question SOLVED - JSON I do not understand why I cannot read this

Unobtainius

Active Member
Licensed User
Longtime User
Code that is doing my head in:
Sub ParseDailyWeatherData(jsonData As String)
    Dim jPaser As JSONParser
    Dim DataMap As Map
    Dim lstBody As List
    Dim HeaderMap As Map

    Try
        jPaser.Initialize(jsonData)
        DataMap.Initialize
        DataMap = jPaser.NextObject
        
        HeaderMap.Initialize
        HeaderMap = DataMap.Get("Headline")
        
        lstBody.Initialize
        lstBody = DataMap.Get("DailyForecasts")
    Catch
        Log(LastException)
    End Try
    
    ShowReady(True)
End Sub

I am just at a loss, I almost never ask for help but in this instance I am bamboozled
In the code above, dataMap looks like a map, as you can see below, but doesn't act like one?
It is the last thing on a Friday so there is a high probability I'm just doing it all wrong
From what I can see the Headline map item is another map, and the DailyForecasts map item is a list
I just cant understand why when I get the Headline and DailyForecasts items into their respective variables, the variables are empty.
I know I must be doing something fundamentally wrong, but I cant see it.
Can someone please help me out?
jsonProblem.PNG
 

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

Unobtainius

Active Member
Licensed User
Longtime User
Wow! that was quick DonManfred
Turns out the data is in the map and the list
I kind of thought damn it, I will just try accessing map items regardless of the what the debugging window says
And it's there

I would be real interested to run this same code in v9.8 to see if I get the same result, but Im too lazy for that
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I would be real interested to run this same code in v9.8 to see if I get the same result, but Im too lazy for that
It will even work in older versions.... JSON is nothing new. The tool i mentioned is a few years old.
And, the way Maps and Lists are working has not changed...
 
Upvote 0

Unobtainius

Active Member
Licensed User
Longtime User
There was nothing wrong with the json I don't have a problem normally, that's why I was so confused
Its just the debugger was telling me the map and the list were empty as you can see in the spoiler picture
 
Upvote 0

Unobtainius

Active Member
Licensed User
Longtime User
Heading home now to start my weekend, its 5:00 on a Friday here.
Thanks for your help Don
 
Upvote 0
Top