Search code examples
diagramsequence-diagramplantuml

new line on plantuml


I've this plantUml

@startuml
!$user = {
           "name": "John Doe",
           "email": "[email protected]",
           "points": 100,
           "language": "en",
           "settings": {
             "notifications": {
               "email": true,
               "push": true,
               "sms": false
             }
           },
           "role": "user",
           "premiumId": "premiumId"
         }

HomePage -> HomePage: show loader
HomePage -> UserEndPoint : GET /user and check the user permissions
HomePage <-- UserEndPoint : $user
HomePage -> UserFriendsEndPoint : GET /user/friends
HomePage -> UserMentorsEndPoint : GET /user/mentors
HomePage -> UserGoalsEndPoint : GET /user/goals
HomePage -> ContentEndPoint : GET /content

and down below is how it's displayed.

enter image description here

How can I format the user data like is in the editor?

I tried to

!$user = {
           "name": "John Doe\n",
           "email": "[email protected]\n",
           "points": 100,
           "language": "en",
           "settings": {
             "notifications": {
               "email": true,
               "push": true,
               "sms": false
             }
           },
           "role": "user",
           "premiumId": "premiumId"
         }

But with this, the diagram is displayed like down below

enter image description here

I tried

"name": "John Doe"\n

or

"name": "John Doe",\n

but both throw me an error.

How can I format like

{
           "name": "John Doe",
           "email": "[email protected]",
           "points": 100,
           "language": "en",
           "settings": {
             "notifications": {
               "email": true,
               "push": true,
               "sms": false
             }
           },
           "role": "user",
           "premiumId": "premiumId"
         }

right now I'm using plantuml for webstorm


Solution

  • The JSON format is probably most useful for diagramming JSON objects. You don't have to use it on a message (although I understand why you did). If all you want is a message for a sequence diagram, you can format it by hand:

    @startuml
    Bob -> Alice : {\n  "name": "John Doe",\n  "email": "[email protected]"\n}
    @enduml
    

    enter image description here

    ETA: With many editors (webstorm?) you have the "join" function that will combine multiple lines into one. Then you only have to add the \n's in the right places.