Is there a way to get a state diagram, but not as an image?

+1 vote
asked Feb 5 in Question / help by magnus (120 points)
I need to generate a specific JSON from a state diagram. I am currently working on a parser using Peggy in javascript, but I'm wondering if there is a way to get a state diagram as code, so I can manipulate the objects and the data to create the JSON that way, or any other format really, that is not an image. I am aware of a few js projects that aim to parse the UML text, like Enteee/plantuml-parser, but none support state diagrams yet.

3 Answers

0 votes
answered Feb 6 by anonymous
edited Feb 6
Use

https://www.planttext.com/

or

https://plantuml.mseiche.de/

or

https://github.com/richardmaley/PlantUMLEditor

@startuml
<style>
  participant {
    BackGroundColor white
    FontColor blue
    FontSize:: var(--default-FontSize);
    FontStyle bold
    LineColor black
  }   

</style>
!pragma teoz true
title Demo Scenario

box "Product boundary" #PaleVioletRed
    participant P1 [
        Participant 1
        ....
        Subtitle
    ]
    participant "Participant A" as DemoA
endbox
box "New Box" #Red/Orange
    participant "Participant B" as DemoB
endbox

P1 -> DemoA
    DemoA <-> DemoB: Do something
DemoA -> P1
@enduml
commented Feb 19 by anonymous
Thanks for the response! Unfortunately it's not what I was looking for. I have the PlantUML code, as well as the state diagram. I need a way to take the UML code and generate a specific JSON format from it. To do this I figure I need to have each state, transition, etc as objects in code, such as JS or Java, that way I could generate the JSON anyway I need.
So far the best option though, seems to be a parser like Enteee/plantuml-parser, but it doesn't support state diagrams yet.
0 votes
answered Feb 21 by dickmaley (4,120 points)

Are you looking for the diagram code so you can parse it?

The save button on https://github.com/richardmaley/PlantUMLEditor captures the code.

Then it is up to you to manipulate it however you desire.

Dick Maley

+1 vote
answered Feb 27 by dickmaley (4,120 points)

This editor allows you to read and write to disk as an image or as code.

https://github.com/richardmaley/PlantUMLEditor

...