Hi there!
Basically, I'm looking to make a custom module to act as a translator to take an incoming OSC message with an integer argument, looks up that integer as a key in a JSON array of objects, and then send out a reply OSC message with a string argument that is a "name" value contained in the looked up/found JSON object.
The JSON data looks something like this
[
{
"id": "Aatrox",
"key": 266,
"name": "Aatrox",
"title": "the Darkin Blade"
},
{
"id": "Ahri",
"key": 103,
"name": "Ahri",
"title": "the Nine-Tailed Fox"
},
{
"id": "Akali",
"key": 84,
"name": "Akali",
"title": "the Rogue Assassin"
},
{
"id": "Akshan",
"key": 166,
"name": "Akshan",
"title": "the Rogue Sentinel"
}
]
So for example, the incoming OSC message would be something like /ChampSelect/Slot1 : 84
I'd then want to translate that into a new OSC message, something like /Video/Layer : "Akali". This would be obtained by looking up the key integer 84 in the JSON array, and returning the "name" value.
I understand very basic JavaScript, and the example "Reply" script makes sense to me. But I'm still very much a beginner and I'm just not sure where to start in terms of having the script sift through and find a JSON object based on its key.
Would anyone be able to steer me in the right direction as to how I might go about doing this?
The full JSON array would contain 150-200 objects. As a bonus, it would be super cool if I could change/select the JSON file using the File widget within Open Stage Control. But that's not necessarily a requirement.
I really appreciate any guidance or direction anyone could give me! Thanks!