This is link to the question: https://forum.plantuml.net/10884/data-structures-json
I test: and that's marvelous! (Thanks a lot)[I posted comment, but that's perhaps better to open a new question here]
And now:
- How to concatenate value from json table?
If, for example (from the example of https://forum.plantuml.net/10884/data-structures-json) I add a field 'game' :
!$data={"partlen": "2", "game": "GamePlantuml", "participants" :[
We test on two differents ways :
- directly:
:with direct concat: $data.game + "_" + $part.name;
- with usage of an intermediate variable ($b)
!$b=$data.game + "_" + $part.name; :with var b: $b;
And on the two way, the result is not done:
- on the first, we observe : 'GamePlantuml + "_" + XYZ'
--> Why the concatenation is not done ? - on the second : '"GamePlantuml"_0'
--> Why we observe '0' and not 'XYZ'? + management of quote (") on var ?
Here is the example used:
@startuml
!$partlen=2
!$data={"partlen": "2", "game": "GamePlantuml", "participants" :[
{"name": "XYZ" ,"as": "xyz"},
{"name": "RST" ,"as": "rst"},
{"name": "UVW" ,"as": "uvw"}
]
}
!$partlen=$data.partlen
!$i=0
:a ;
:$i;
:$partlen;
!foreach $part in $data.participants
:$part.name as $part.as;
:with direct concat: $data.game + "_" + $part.name;
!$b=$data.game + "_" + $part.name;
:with var b: $b;
!endfor
:b;
@enduml |
http://www.plantuml.com/plantuml/uml/VL39QiCm4BtFLqm6tsf2oL76a5klfVj2AUEbYS1HWgGaROF_lJE9Yj9BB_AyvJqUdeV8FcvN0qoAZLn3x-gPt1r7hW-KA398CogH5hpg5Lp9ztfWfqdbrMTRkn4c49fNE91BrgVd5yAIE2Zu_FgciJnJRsxlikf3_AlUFpncTRlRqmXlC9vDFUwS9YIyhIy14S4mLc0AgqzIAvXyh7tFxHAF55g7EVux7X1FYQbkG0vuGXmgbVOsBh6plcyZjclNSZIfPA7s2wHtaZStQ6fIDFM_fbozOu-DL3QojdUT30OZzrnk-TC_