Composite state functionality with allow_mixing

0 votes
asked Jan 13, 2023 in Question / help by Vantage0542 (120 points)

I'm trying to use composite state functionality with allow_mixing and running into some issues. It appears that you cannot use composite states and allow_mixing at the same time.

For example,

@startuml

state "A" as stateA {
    state B
}
@enduml

Renders without issue.

However,

@startuml
allow_mixing

state "A" as stateA {
 state B
}
@enduml

Gives a syntax error on line "state "A" as stateA {"

Additionally,

@startuml
allow_mixing

state "A" as stateA
@enduml

Renders without issue.

For context, I am trying to insert a table of conditions/information into a state or conditional of a state diagram. To achieve this, I am trying to mix json data into the diagram, but running into the issue above.

Is there a way to get allow_mixing to work with composite states? Or perhaps I am approaching the way I want to achieve a table/json data inside a state incorrectly?

1 Answer

+1 vote
answered Jan 13, 2023 by plantuml (297,680 points)
selected Jan 20, 2023 by Vantage0542
 
Best answer

You can now have this with last snapshot:

@startuml
state "A" as stateA
state "C" as stateC {
 state B
}
json foo1 {
  "foo2": "foo3"
}
@enduml

Hope this helps!

commented Jan 20, 2023 by Vantage0542 (120 points)
Thank you, that has solved what I was trying to do!
commented Sep 3, 2025 by Eric Jiang

I can insert this json data like:

{
  "foo2": "foo3"
}
But, if my data is a list, like List<String> in java.
["foo2", "foo3"] 
I think this is also a kind of json data. But the plantuml show the error message.
commented Sep 3, 2025 by The-Lu (87,240 points)

Hi E.,

For that case, you must put all the list on a one-line, as:

@startuml
state "A" as stateA
state "C" as stateC {
 state B
}
json foo1_JSON_title  ["foo2", "foo3"]
@enduml

Enjoy,
Regards,
Th.

commented Sep 3, 2025 by Eric Jiang
Hi, Thanks for answer the question!

I use the Intellij Idea plugin named "plantuml4idea", the plantuml4idea's version is 6.4.0-IJ2022.2(because my idea's version on my computer is Intellij Idea 2023.1.3 Community Edition).

So if there is any version of plantuml4idea that can help me to insert "list" into the "state"?

thanks very much!
commented Sep 5, 2025 by The-Lu (87,240 points)

Hi E.,

Here is another example, with embedded JSON directly on State:

@startuml
state "A" as stateA
stateA : {{json%n()["foo2", {"f":1}]%n()}}
state "C" as stateC {
 state B
 B: {{json%n(){"foo2": [1 , 2, 3]}%n()}}
}
json foo1_JSON_title  ["foo2", "foo3"]
@enduml

Enjoy,
Regards,
Th.

commented Sep 5, 2025 by Eric Jiang

Hi, thanks for the response! 

I found the reason about why I can not use 

B: {{json%n(){"foo2": [1 , 2, 3]}%n()}} 
in my idea.
My jetbrain idea's version is 2023.1 community, so I can only use the plantuml4idea[6.5.0-IJ2022.2]. This gramma doesn't work in this plugin version. and I can not change or update my jetbrains' version on my computer...
Also, I found my friend's jetbrain idea's version is 2023.3.2, He can use the plantuml4idea[7.13.0-IJ2023.2], and that can works on my friend's computer.
Can you help me to publish a new plantuml4idea version that can works on my intellij idea 2023.1 community? Thanks very very much !
...