[ANSWERED/LOGGED] JSON Bundler Question
-
Hello,I have just started work on another instalment of our improvised sound video collective FFoB (from the Troikatronix front page featured gallery) and am diving back into Isadora. I am very excited to be back working with Isadora and engaging with you all.
I am working with a Loupdeck and a Stream Desk in MIDI mode this time around, which will make everything so much easier for me. It does, however, mean several hundred midi CC and Note values.
I am delighted to see the JSON actors and am doubly excited to learn about nestling JSONs. This is a very very powerful feature that will simplify the midi controller snapshot component of my project immensely. With some simple math, I will be able to bundle CC and Note values by button, page and channel numbers. Depending on overhead, this will allow me to put everything into one big JSON and pull values based on nestled "KEYS". For example, watching for touch button 5 from page 6 of workspace 3 (which is set to midi channel 3). Glorious.
Will I notice any hit to overhead working this way?
Also I have noticed a small thing with these actors. When copying a JSON Bundler that has many inputs and key values, the output type will switch to "ARRAY" instead of "OBJECT". In order to get it back to "OBJECT", I have to edit one of the "KEY" fields. Once I do this, it will bump back to "ARRAY".Is this a small bug or is it something I am doing incorrectly? If it is a bug, it is certainly not a critical bug.
-
@jtsteph said:
Will I notice any hit to overhead working this way?
I would be extremely surprised if you experienced any noticeable overhead hit due to just data processing.
-
@jtsteph said:
Also I have noticed a small thing with these actors. When copying a JSON Bundler that has many inputs and key values, the output type will switch to "ARRAY" instead of "OBJECT". In order to get it back to "OBJECT", I have to edit one of the "KEY" fields. Once I do this, it will bump back to "ARRAY". Is this a small bug or is it something I am doing incorrectly? If it is a bug, it is certainly not a critical bug.
This has already been logged and fixed in our most recent internal beta.
-
@jtsteph said:
the output type will switch to "ARRAY" instead of "OBJECT"
If this is causing real issues for you (I recently had this issue) you can use Javascript to bundle your JSON. I have created rather complex project using this method without issue.
see: Grouping, Ungrouping and Passing JSON Values With Javascript : TroikaTronix -
@dusx Thanks for this. It's not causing a huge issue for me - the workaround is quite easy. Where I am encountering a more substantial issue is with Javascript. I am using it to calculate my midi controller numbers by page. I'll do another post on this to make it searchable.
-
And just to confirm here, the output from the JSON Parser is always text? I am using the Text Parser to change the data type to integer currently. Is this best practice?
-
@jtsteph said:
And just to confirm here, the output from the JSON Parser is always text? I am using the Text Parser to change the data type to integer currently. Is this best practice?
Yes, JSON is text, and the data is untyped. Text Parser is a good choice to use, You can also pass the 'text' number into a JS actor, and simply pass if back out with out modification, the JS actor will allow you to mutate the value to a number. It sounds like you have it working well though.
-
@dusx Thank-you. I am always happy to hear about different ways of doing things incase one method does not suit the patch.
-
Just quick update on this. The JSON Bundler always seem to revert to object when I open my project. I have worked around this by including a "trigger text" actor to send a "key" to the jason bundler as a part of the scene initialization. This resets it to object. I'll see if this works moving forward, if not, I will use @DusX 's javascript option.Definitely having issues with the bundler and unpredicably switching to "array". I am going to pivot to dusx's javascript method. Here is what i did to be able to add a custom key to the json values so i can use the isadora JSON Parser actor:
--------------
// input 1 (index 0) is the custom string for the key. The loop begins at 1 as opposed to 0
function main() {
var customString = arguments[0]; // takes custom key string from input 1
var output = {};for (var i = 1; i < arguments.length; i++) {
// Creating a new key with custom string and index
var key = customString + i;
output[key] = arguments[i];
}return JSON.stringify(output);
}