Data Structures JSON: How to concatenate values from json table?

0 votes
asked Apr 6, 2020 in Question / help by The-Lu (12,840 points)

This is link to the question:
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 I add a field 'game' : 

!$data={"partlen": "2", "game": "GamePlantuml", "participants" :[
  • How to refer to '$' on the 'for loop'?

We test on two differents ways :

  1. directly:
     :with direct concat: $ + "_" + $;
  2. with usage of an intermediate variable ($b)
  !$b=$ + "_" + $; :with var b: $b;

And on the two way, the result is not done:

  1. on the first, we observe : 'GamePlantuml + "_" + XYZ' 
    --> Why the concatenation is not done ?
  2. on the second : '"GamePlantuml"_0'
    --> Why we observe '0' and not 'XYZ'? + management of quote (") on var ?

Here is the example used:

!$data={"partlen": "2", "game": "GamePlantuml", "participants" :[
{"name": "XYZ" ,"as": "xyz"},
{"name": "RST" ,"as": "rst"},
{"name": "UVW" ,"as": "uvw"}
:a ;
!foreach $part in $data.participants
  :$ as $;
  :with direct concat: $ + "_" + $;
  !$b=$ + "_" + $;
  :with var b: $b;

1 Answer

0 votes
answered Apr 6, 2020 by plantuml (241,480 points)
selected Apr 7, 2020 by The-Lu
Best answer

Many thanks for your tests!

We have fixed several bugs in last beta (including quote management)

The online server runs now with this beta.

  • By design, you cannot use "direct concat" because the parser is not clever enough. However, using an intermediate var (!$b) is not very user friendly so we have added a new %string() function you can use in that case (see examples)
  • Be carefull : there was an ending semicolon in your $b affectation, and this confuse the parser. Ideally, we should print an error message in that case. Right now, we do not yet :-)
Here are two working examples :
Please go on with your tests !
Thanks again !