4 releases
| 0.3.3 | Oct 1, 2025 |
|---|---|
| 0.3.2 | Jul 30, 2025 |
| 0.3.1 | Jul 28, 2025 |
| 0.2.1 | Jul 22, 2025 |
#1890 in Parser implementations
312 downloads per month
72KB
1.5K
SLoC
scjson Rust Crate
This directory contains the Rust implementation of scjson. It offers a command line tool and supporting library to convert between .scxml and .scjson files and to validate documents.
For details on how SCXML elements are inferred during conversion see INFERENCE.md.
Installation
cargo install scjson
You can also build from this repository:
cd rust && cargo build --release
Source Code - Multi-Language Support
https://github.com/SoftOboros/scjson/
- csharp
- go
- java
- javascript / typescript
- lua
- python
- ruby
- rust
- swift
Command Line Usage
scjson json path/to/machine.scxml
scjson xml path/to/machine.scjson
scjson validate path/to/dir -r
Known Issues
None at this time.
Operational conformance testing is performed via uber_test.py
/py# python uber_test.py -l javascript 2>&1 | tee test.log
Note: uber_test.py applies all scxml files in Zhornyak's ScxmlEditor-Tutorial which provides a robest set of scxml test vectors useful for standard compliance verification. This is the only file in the test suite which fails to verify round-trip.
Enums
Each enumeration represents a restricted string set used by SCXML. The values shown below mirror those defined in the SCJSON schema.
AssignTypeDatatypeProps– how the<assign>element manipulates the datamodel. Values:replacechildren,firstchild,lastchild,previoussibling,nextsibling,replace,delete,addattribute.BindingDatatypeProps– determines if datamodel variables are boundearlyorlateduring execution.BooleanDatatypeProps– boolean attribute valuestrueorfalse.ExmodeDatatypeProps– processor execution mode, eitherlaxorstrict.HistoryTypeDatatypeProps– type of<history>state:shallowordeep.TransitionTypeDatatypeProps– whether a<transition>isinternalorexternal.
Common Types
Several generated classes share generic helper fields:
other_attributes:Record<str, str>capturing additional XML attributes from foreign namespaces.other_element:list[object]allowing untyped child nodes from other namespaces to be preserved.content:list[object]used when elements permit mixed or wildcard content.
Document / Object Types
AssignPropsAssignArray– update a datamodel location with an expression or value.CancelPropsCancelArray– cancel a pending<send>operation.ContentPropsContentArray– inline payload used by<send>and<invoke>.DataPropsDataArray– represents a single datamodel variable.DatamodelPropsDatamodelArray– container for one or more<data>elements.DonedataPropsDonedataArray– payload returned when a<final>state is reached.ElseProps– fallback branch for<if>conditions.ElseifProps– conditional branch following an<if>.FinalPropsFinalArray– marks a terminal state in the machine.FinalizePropsFinalizeArray– executed after an<invoke>completes.ForeachPropsForeachArray– iterate over items within executable content.HistoryPropsHistoryArray– pseudostate remembering previous active children.IfPropsIfArray– conditional execution block.InitialPropsInitialArray– starting state within a compound state.InvokePropsInvokeArray– run an external process or machine.LogPropsLogArray– diagnostic output statement.OnentryPropsOnentryArray– actions performed when entering a state.OnexitPropsOnexitArray– actions performed when leaving a state.ParallelPropsParallelArray– coordinates concurrent regions.ParamPropsParamArray– parameter passed to<invoke>or<send>.RaisePropsRaiseArray– raise an internal event.ScriptPropsScriptArray– inline executable script.ScxmlProps– root element of an SCJSON document.SendPropsSendArray– dispatch an external event.StatePropsStateArray– basic state node.TransitionPropsTransitionArray– edge between states triggered by events.
Other Resources
github: https://github.com/SoftOboros/scjson
git clone https://github.com/SoftOboros/scjson.git
git clone git@github.com:SoftOboros/scjson.git
gh repo clone SoftOboros/scjson
npm: https://www.npmjs.com/package/scjson
npm install scjson
pypi: https://pypi.org/project/scjson/
pip install scjson
dockerhub: https://hub.docker.com/r/iraa/scjson (Full development environment for all supported languages)
docker pull iraa/scjson:latest
All source code in this directory is released under the BSD 1-Clause license. See LICENSE and LEGAL.md for details.
Dependencies
~1.5–2.6MB
~49K SLoC