Some HTTP request yields us a bunch of information about some specific device.
The text from HHTP output looks like:
[...]
c.1.tilt:=-846
c.1.tilt.status:=0
c.1.tilt.min:=-3000
c.1.tilt.max:=9000
c.1.tilt.limit.min:=-3000
c.1.tilt.limit.max:=9000
[...]
All in all there are about 1140(!) lines of text returned... :-)
I want to make this into a collection (or k/v array), so that I could specifically search for individual keys like 'c.1.tilt.min'.
Using a TextSlice and a SetCollectionText within an array doesn't seem to work.
(Apart from the fact that arrays max out at 1000 loops... :-/)
Thanks for any hint!
Eric.
Hi Eric,
Well, this is quite tricky but possible.
What you need to know is that Transmit modules can be used as an Array Add/Blender like module. They can transmit values for the next array loop. And at the end, they are used to get out the final value from the loop.
So this is what you need to set up inside the array compound:
And you will need a transmit module outside of the array compound for the final value:
You can get over the 1000 array compound limit by having array compounds within array compounds. But note that the transmit modules are a bit unoptimized currently, so 1000 of them already significantly reduce the CPU performance.
However, you could also just search for the given key within the text, using the following setup:
This works by slicing the text until the search term and then slicing the rest starting from the next line.
Note, there is also the Text Contains module, which can detect if such a key exists in the text. I guess in the future Aximmetry could add a more complex slice module that could do all this with only one node.
I suspected in both examples that each value is in new lines. If it is not so, you will need to change the above examples.
Warmest regards,