JSON data streams

I must be being silly because I can’t work this one out.

I have a Json data stream containing updated x and y coordinates for a 100 objects.
Looks something like this,

{“height”:900,“points”:[{“Id”:0,“Size”:11,“X”:135,“Y”:225},{“Id”:1,“Size”:14,“X”:115,“Y”:202},{“Id”:2,“Size”:11,“X”:81,“Y”:34},{“Id”:3,“Size”:9,“X”:143,“Y”:175}…

I want to merge a list of all the xy coordinates (they’re updating 15fps)

Using the [find subtrees with name] I can see the content but how do I get at it, how do I merge the lists?

much appreciated :)
M

I’m not a tree pro anyhow so maybe there are way better solutions, or maybe we could need some more nodes, some more conversion nodes or nodes to handle lists of trees, but if 15 fps allows it you could for example use :

 

Process Trees To Values.vuo (3.4 KB)

Think I may have it, but it’s a bit slower than expected, am I going about this in the right way?

1 Like

Haha our posts crossed.

Maybe if you use “copy layer” instead of a second “process lists” node to parse the XY values it would be faster ?
Maybe Iteration: Turn most nodes into iterators by allowing single-value ports to accept lists will also be faster for this.
But still, maybe the team has a better option ;)

1 Like

Thanks @bodysoulspirit

Looks like I almost got there, omitting the get tree content node feels like its made it a little faster. I wonder if I could get better results if the coordinates were listed in a different way so we don’t have to have so many processed list nodes. Will report back. Thanks again for the quick response!
Safeness&Greatness
M

Yeah, and again, maybe “Copy Layer” will be faster than Process List too.
And you also have your layers size set to 8. 100 layers with an 8 width & height could be pretty heavy anyway I guess.

 

Process Trees To Values 1.1.vuo (4.58 KB)

Yes maybe encoding the values in another way could help.

And if Get Tree Content would export a list of values (or a space separated values block of text) we could use that.

Another method is to use split text (joined composition), maybe that would work as a workaround, test what is faster :

 

Tree As JSON Text Split.vuo (3.23 KB)

I’m getting much better results parsing the data by splitting the text than processing two X and Y lists and merging them. Up to almost 15fps which is ideal. Thanks again @Bodysoulspirit

1 Like