Went back to this after a few days. My issue was that the "rank" item in the JSON page wasn't formatted standard so I put in a line of code to convert it to a string first. I seem to solve my own problems half the time after posting on these forums.
Original Message:
Sent: 09-01-2022 13:17
From: Jake Lew
Subject: Dashboard - Call Data from online JSON and send to local XML
So, I've got the Struct Table working perfectly for storing home and away team rosters. Just looking at doing the same thing to pull standings now... cause why not, I thought it would be easy enough. However, for whatever reason I can't duplicate my results with it. It is weird. Code is below:
function callback(resultStr){ if (resultStr != null) { var json = JSON.parse(resultStr); for (var n=0;n<50;n++){ var rank = json.SiteKit.Statviewtype[n].rank; var name = json.SiteKit.Statviewtype[n].team_name; if (name != null) { ogscript.debug('Adding Entry: ' + rank); ogscript.debug('Adding Entry: ' + name); var structCount = params.getElementCount('Conference_Standings');if (structCount == 1 && params.getValue('Conference_Standings.0.Rank', 0) == "") // If this is the first element and it has not been set yet{structCount = 0;}var newValue = { "Rank": rank, "Name": name, };ogscript.debug("newValue: " + newValue);params.setValue('Conference_Standings', structCount, newValue);}} } } var URL = params.getValue('Conference_StandingsURL', 0);ogscript.asyncPost(URL, null, callback);
The weird parts are:
- With this current script I only see in the debug monitor, it adding the first entry of rank/name, but it doesn't add it to the table.
- If I take away the "params.setValue('Conference_Standings', structCount, newValue);" line, I can see in the debug monitor that it adds all rank/name entries just fine.
- If in setting the newValue I put something other than the rank/name variables in there, it sets the values just fine for the appropriate number of teams... just obviously not with the variable values that I want to be in there. (When I do this I see all the entries add in the debug monitor as well... so it seems like having the variable in the newValue is what breaks it... but that doesn't make sense because that's exactly what I'm doing for the roster ones that work fine)
So not sure what I'm doing wrong on this one.
------------------------------
Jake Lew
Access Communications Co-Operative Limited
Original Message:
Sent: 08-05-2022 08:19
From: Aleksander Stalsberg
Subject: Dashboard - Call Data from online JSON and send to local XML
That looks perfect to me!
Now I would recommend looking into Struct Tables in order to store the data.
From there you can put all of this data into an organized table, and then call the info from that table into whatever information you need to populate individual Xpression Graphics for example.
------------------------------
Aleksander Stalsberg
Inland Norway University of Applied Sciences/Lillehammer Icehockey Club
Norway
Original Message:
Sent: 08-04-2022 16:30
From: Jake Lew
Subject: Dashboard - Call Data from online JSON and send to local XML
I think I have figured it out. Might not be the neatest code, but it proves the concept of what I need to do. I will share what I have done here for future knowledge seekers:
Looking at the URL: https://lscluster.hockeytech.com/feed/?feed=modulekit&view=statviewtype&type=skaters&key=41b145a848f4bd67&fmt=json&client_code=whl&lang=en&season_id=275&team_id=212&league_code=&fmt=json&sort=active&order_direction=
Code that takes three items from there, could be expanded on to take more, but this gives the basic idea:
function callback(resultStr){var number;var name;var position;var numberArray = new Array();var nameArray = new Array();var positionArray = new Array(); if (resultStr != null) { var json = JSON.parse(resultStr); for (var n=0;n<50;n++){ number = json.SiteKit.Statviewtype[n].jersey_number; name = json.SiteKit.Statviewtype[n].name; position = json.SiteKit.Statviewtype[n].position; if (name != n) { ogscript.debug('Adding Entry: ' + number); ogscript.debug('Adding Entry: ' + name); ogscript.debug('Adding Entry: ' + position); numberArray.push(number); nameArray.push(name); positionArray.push(position); } params.setAllValues('Home.Numbers', numberArray); params.setAllValues('Home.Names', nameArray); params.setAllValues('Home.Positions', positionArray);} }}var URL = params.getValue('URL', 0);ogscript.asyncPost(URL, null, callback);
------------------------------
Jake Lew
Access Communications Co-Operative Limited
Original Message:
Sent: 08-03-2022 09:10
From: Aleksander Stalsberg
Subject: Dashboard - Call Data from online JSON and send to local XML
This is definetly possible, but how complex it ends up being depends on what you plan to use it for.
In my case, I have a full table of the teams info, and with that list I have the name, the short version, the logo-path, the primary and secondary color and team statistics as well. But most importantly, a team ID (acting as primary key if you know database logic).
Using that, I then have another table for each player, their name, pic, number, stats, so on... And also what team they play on (by id). Pulling data from a player also gives me the info of what team they are on, and pulling up a team, I can make a list of each player on that team, so on so forth...
So based on that, I pull the teams from the league with JSON, populate that table first. Then I have another button that lets me pull the individual player data from all players on the selected team, and also for todays match. And each of these players also have their own player ID.
Takes some planning to set it up in a way that you dont end up with a ton of redundant data and/or alot of manual entry if not everything is pulled from the JSON data as well...
I dont have time right now to give you an example, but parsing the JSON data is fairly simple.
Look here for some examples: https://www.w3schools.com/js/js_json_parse.asp
------------------------------
Aleksander Stalsberg
Inland Norway University of Applied Sciences/Lillehammer Icehockey Club
Norway
Original Message:
Sent: 08-02-2022 11:12
From: Jake Lew
Subject: Dashboard - Call Data from online JSON and send to local XML
Our hockey project is also quite large, but with the season coming up I've just been starting to look briefly at what I could do to improve/better things. One of the things that immediately came to mind was that it seems like a shame that our operator has to manually update roster spreadsheets before each game, when we are connected to the internet and it is all there just for the taking (if I knew how). I didn't build the original projects and haven't dived to deep into how they are built, so no guarantee I'd even be able to wrap my head around changing it off pulling data locally from spreadsheets to pulling it from the internet..... but the first step would be to see if it was possible to grab it from the net and how to do it.
------------------------------
Jake Lew
Access Communications Co-Operative Limited
Original Message:
Sent: 07-31-2022 20:00
From: Aleksander Stalsberg
Subject: Dashboard - Call Data from online JSON and send to local XML
Hi there!
Yes I made some major progress to this, and have a working dashboard, that can pull data from a whole host of players from different leagues and use that data for any graphics or data in XPression...
It is a rather large project though, but if you can narrow it down to what you're looking for first, I'll see if I can answer.
------------------------------
Aleksander Stalsberg
Inland Norway University of Applied Sciences/Lillehammer Icehockey Club
Norway
Original Message:
Sent: 07-28-2022 16:49
From: Jake Lew
Subject: Dashboard - Call Data from online JSON and send to local XML
Hi,
I realize this is a few years old, but it is exactly what I am looking at right now. Online JSON feed from that same site/structure: https://lscluster.hockeytech.com/feed/?feed=modulekit&view=statviewtype&type=skaters&key=41b145a848f4bd67&fmt=json&client_code=whl&lang=en&season_id=275&team_id=212&league_code=&fmt=json&sort=active&order_direction=
Trying to figure out how I can parse that and add some (but not all) of that data into Dashboard for use.
Either of you guys ever make any progress with this?
------------------------------
Jake Lew
Access Communications Co-Operative Limited
Original Message:
Sent: 11-18-2019 20:18
From: Justin White
Subject: Dashboard - Call Data from online JSON and send to local XML
Did you make any progress with this? I am trying to do the exact same thing, hockey stats via LeagueStat, any would love to work on this with you if you are still working on it.
#DashBoard