How to escape {} in activity diagrams?

0 votes
asked Oct 29, 2021 in Question / help by sashee (200 points)

I want to add a JSON to a an activity, but I'm getting errors with curly braces.

Here's how it does not work: https://www.plantuml.com/plantuml/uml/SoWkIImgAStDuR9IIaaiILIoKgZcKW02fSoIr5mu3ooIbfcQas8855CgIIqkKIXABIx8pojELGAhgEMgjUPoICrB0Pe50000

Strangely, it I add a \ after the } it works, but now the two braces are on the same line: https://www.plantuml.com/plantuml/uml/SoWkIImgAStDuR9IIaaiILIoKgZcKW02fSoIr5mu3ooIbfcQas8855CgIIqkKIXABIx8pojELGAhg8tXghNcSaZDIm4Q1W00

The only way I could make it work is by adding a \t: https://www.plantuml.com/plantuml/uml/SoWkIImgAStDuR9IIaaiILIoKgZcKW02fSoIr5mu3ooIbfcQas8855CgIIqkKIXABIx8pojELGAhg8qfuQgrvd98pKi1cWO0

But it's ugly and I feel there should be a better way to do it. Am I missing something trivial?

commented Oct 29, 2021 by Martin (8,320 points)
edited Oct 29, 2021 by Martin

Looks like a parsing bug to me.  It  doesn't like having "}" as the last character on a line in an activity.

I couldn't find anything nicer than your "\t".  But another workaround is to use Unicode full-size curly brackets instead:

commented Oct 29, 2021 by The-Lu (49,840 points)

Hello all,

It is a big deal, between an greedy or lazy analyser.

Compare:

@startuml
:a}
@enduml

with:

@startuml
:a
}
@enduml

with:

@startuml
:a};
@enduml

with:

@startuml
:a}
;
@enduml

Then see similar issues here:

And for Unicode workaround, see also here (as for semi-colon, or bracket)

Regards,
Th.

commented Oct 30, 2021 by Martin (8,320 points)

doh, of course; I forgot that the last character of an activity defines its shape, as documented at https://plantuml.com/activity-diagram-beta#7420c7766a064a28.  I can see that it is tricky to parse, it would need to backtrack if it hit a syntax error or something.
 

Maybe it would be easier to fix the following.  Where it seems obvious that the <code> enclosure should wait for the </code> end tag in preference to the activity terminator.  This might not give the OP the formatting that they want, but it is the kind of thing that the <code> tag is built for.

@startuml
:<code>
"data": {
    "item": {
        "field1": "test response"
    }
}
</code>;
@enduml

commented Oct 30, 2021 by The-Lu (49,840 points)

Hello all,

For <code> issues, see also here:

Regards.

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.
...