There are two blocks that may be of value for you. I've implemented a version with list by walking key path but you could also use get value at key path if you know that you only want the away team for the first game for the first date. You can do that by substituting the value 1 for the walk all at level blocks in the following code:
The difference is that the former will return a list of all possible values where walk all at level acts as a wildcard whereas the latter will return the first value matching the given path.
Thank you for this. Now let me see if I understand what you are doing here as I am not very familiar with the Dictionary blocks.
Your version will give me a list of all the Away team names available for that particular date? I am not sure what the "walk all at level" block does.. but it appears to be an Index of some sort?
Yes, let me expand on that, but essentially the walk all at level block acts as a wildcard.
Effectively, you can read the list in reverse... that is "give me a list the of name of the team of the away of the teams for allgames for alldates. If your endpoint returns a set of games for a specific team then you'll get a list of away teams head-to-head against that team. If the endpoint returns all home vs away games then you'll get a result with a different shape (the output logically mirrors the input). My code example was based on the screenshot you provided so depending on the whole response it may be different.
What I am trying to do is create a ticker of sorts, one that will display the Home and Away team for each game.. the games are for one day only, and there will be a different number of games each day.
The JASON file gives me all of that data on a daily basis so I will need to be able to refresh it each day.
I can see that it would be easy to substitute Home for Away in the list of tags, thats easy enough.
Pulling the rest of the data using your method may take a little work but this is also a learning experience for me. Scores, maybe the time on the game clock, and the number of games each day will be about it.
Let me figure this much out before I dive into the rest of that. Baby steps.
Thanks @ewpatton I worked out my issue. Your method is a lot cleaner than mine was and I learned a little bit about using Dictionaries.
I do have another JSON issue though.. I worked out everything when there is data in my JSON import. But there will be occasions where sometimes there is no data. For example, my JSON data is of NFL football games. The NFL schedules games about 4 days a week. Sunday of course, Monday night, Thursday night, and sometimes Saturdays like in the playoffs. On a Tuesday for example when there are no games my Events tag is empty..
When my blocks execute on a gameday all is well because there is data to read. On a non-game day I get the following error:
..and I understand why. My question is how to handle this error gracefully .. when I try to check to see if list "Events" is empty I still get this error, I am guessing because the value is null? I cannot read a list/index of 1 if it does not exist. Is there a check for this and I just don't know about it?
Here are my blocks checking for data as of right now..
I think I understand what you are telling me but I am not sure your solution will work either? If I understood you then here is what I have now.. is this what you were saying?
I see part of our confusion. The first part of this thread was for a completely different project. That issue is resolved. I am guessing I should have started a new post completely for this one. My apologies there..
If you load this up you will see the two text blocks defining the URL for WEB1 .. the one on top does not work and the one on bottom does. One is an actual game day and the other is not. The JSON data file is different for a game day than it is for a non-game day.
I understand what you are suggesting but that's not what I am asking/needing. The check generates an error because the list is empty/null on a non-game day. I am not able to check for values if they do not exist.
I am just trying to figure out how to handle a non-game day when this error is generated. Is there a graceful way to handle this error?
Wow. Outstanding. I looked at your version and see how you handled my issue.. very creative. I do not know that I would have come up with that on my own. This solves my problem and I really appreciate the help.
I did learn from your solution and will be sure to use this technique in the future.
Did you ever finish this app? I am curious what the final product / solution is. Like did you create a Ticker Arrangement group for the 16 weekly games and make one invisible if no game that week ?
Or some other method ?