How to get data from dict embedded with special structure json
Hi Maxers,
Some of you may know that the movements data (two-dimensional coordinates in the court) of individual players for past MBA games are available as json files.
https://github.com/linouk23/NBA-Player-Movements
I imported this data into a dict object. I can get the team name, player name, etc. with "get" message, but I am not able to get the values for key "moments" and Max always crashes.
This value includes the many positional coordinates of a ball & 10 players in succession, but it seems to be a complex hierarchy structure consisting only of numbers, commas, and parentheses, not including any key symbols.
I would appreciate suggestions on how to get each positional coordinates data separately.
Thanks
I think the issue is related to the problem mentioned in the link. See Jan's reply for an explanation and you can probably adapt the Js to your case.
Amazing! If I could modify this, it seems like my problem will be solved.
Thank you!
Thanks to you, I feel like I'm only one step closer to a solution, and I deeply appreciate LUVULONGTIME and JAN.
However, I am a javascript newbie and I still do not fully understand how to retrieve an array within an array. It would be great if I could get some more suggestions.
I think it's another array so if i'm correct you need another for-loop. I'm not behind Max right now so i can't check for sure.
<Edit> what's the output from "numMoments"? 1 by any chance?
I don't know if you know or use Proccessing by any chance? I generally use that to parse Json as it's a bit more userfriendly in this case and will tell you if it's an array or object (ie. the program simply won't run but at least it will tell you why :)
<Edit> And thank Jan btw, not me. I just recognized the issue
Thank you LUVULONGTIME!!
I have just found a way to solve this problem!
I seem to be gradually learning the javascript and am getting the output I need.
Nice! How did you solve it though? Was it simply reading through another for-loop or something else?