Hi Tony,
thanks for taking your time and your extensive reply. Perhaps I've made it too complicated. Ok, I try to reformulate it. Disclaimer also: I work in a corporate environment, so I'm not completely free in the tools I am allowed to use (to my surprise, Node.js is ok - yessss!) and how much information I can disclose.
Let's put it that way: I have set up an internal information repository which contains more or less textual information only so far. But now and then, I would like to display some figures. And I would have to perform some simple arithmetics with that figures (basically summing up).
Let's call the things I am looking at "facilities". A "facility" should be displayed in a templated tiddler, displaying textual and quantitative information. Each "facility" can feature several "units" (that's the 1:n relation), figures for which should also be displayed and/or shown as a grand total.
The data for the facility/unit information should initially come from an Excel table. For further use (the CRUD part), I would like to create a TW-based interface. As "facility" is a comprehensive entity for my purposes, I thought it would be ok to store it in a nested JSON tiddler, i.e. store the units per facility in a JSON array. This, of course, breaks the RDBMS dogma, but it saves me from having to fiddle with primary keys. Mimicking a RDBMS in TW is definitely not a rabbit hole I want to jump into. If I needed something like that, I would try if I could connect a DB backend via Node.js (in my special environment I would end up with SQLite or ODBC), and let this do the grunt work.
All this being said, here's the core of my question: Accessing nested JSON data using Joshua Fontenay's JSONMANGLER plugin works great, as long as the index position is known, but I need a way to determine the length of a variable-length array in a JSON structure, for not running out-of-bounds while looping into the nested data. I understand $:/History is such a variable-length array, and thanks for pointing me at this. In that case, maybe I need to look up how data are retrieved from there. I know, as a workaround, I still could store the number of units as a data field in the JSON structure, but then I would have to take care of it programatically, which I want to avoid.
Thanks again and apologies for any confusion I caused
Werner