spiff-arena/SpiffWorkflow/doc/non-bpmn/tutorial/serialize-wf.py

15 lines
471 B
Python
Raw Normal View History

import json
from SpiffWorkflow import Workflow
from SpiffWorkflow.serializer.json import JSONSerializer
from nuclear import NuclearStrikeWorkflowSpec
serializer = JSONSerializer()
spec = NuclearStrikeWorkflowSpec()
workflow = Workflow(spec)
data = workflow.serialize(serializer)
# This next line is unnecessary in practice; it just makes the JSON pretty.
pretty = json.dumps(json.loads(data), indent=4, separators=(',', ': '))
open('workflow.json', 'w').write(pretty)