I would really like to modify JSON variables in the preprocessing, especially for the arrays. For example:
!$data = {"a": ["b", "c"]}
!$data.a[] = "d"
!$data.a[] = {"e": "f"}
!$data.x = "y"
%unset($data.a[0])
Which would result in:
{"a": ["c", "d", {"e": "f"}], "x": "y"}
Is this feasible?
Some context:
I want to create a plantUML library for event modeling, written in the preprocessor language. It would (ab)use the deployment diagram for this purpose.
The challenge is that the natural ordering for event modeling is different from the ordering required to create the correct plantUML diagram (I've got the correct layout working, so I'm very pleased with that). My planned approach was to use functions to construct a large JSON variable (with arrays), and then write a render function to convert the JSON variable to a diagram. But then I found out that I can't modify JSON variables...
As an alternative, I figured out that I can fake arrays in the preprocessor with such an approach:
!$i = 0
%set_variable_value("array" + $i, "a")
!$i = $i + 1
%set_variable_value("array" + $i, "b")
!$r = %get_variable_value("array1")
I could probably get it working with this approach, but it makes my eyes bleed so I would prefer to avoid that.