Modify JSON variables in preprocessor

0 votes
asked Feb 23 in Wanted features by Marries (120 points)

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"

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.

commented Feb 23 by The-Lu (55,740 points)

Hello M., and all,

Just FYI, here are some pseudo-similar requests here:


commented Feb 27 by Marries (120 points)
Thanks, I didn't find those topics. It seems this feature won't be added soon so I'll continue with my proposed alternative and keep tissues at hand. Cheers!

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.