moonrockz/diagrams-plantuml/json
Types
Conversion
pub struct Conversion {
tree : @moonrockz/diagrams/data-tree.DataTree?
diagnostics : ReadOnlyArray[@moonrockz/diagrams.Diagnostic]
}The result of converting a document to a data tree.
Document
pub struct Document {
name : String?
statements : ReadOnlyArray[@moonrockz/diagrams-plantuml/envelope.Statement]
highlights : ReadOnlyArray[@moonrockz/diagrams-plantuml/data.Selector]
value : Value
} derive(Eq, @moonbitlang/core/debug.Debug)One parsed JSON diagram block.
Document::equal
fn Document::equal(Document, Document) -> BoolDocument::logical_equal
fn Document::logical_equal(self : Document, other : Document) -> BoolCompare two documents without spans and source spellings.
Document::new
fn Document::new(value : Value, name? : String, statements? : ArrayView[@moonrockz/diagrams-plantuml/envelope.Statement], highlights? : ArrayView[@moonrockz/diagrams-plantuml/data.Selector]) -> DocumentA document. The constructor copies its arrays.
Document::not_equal
fn Document::not_equal(x : Document, y : Document) -> BoolDocument::to_repr
fn Document::to_repr(Document) -> @moonbitlang/core/debug.ReprMember
pub struct Member {
name : Str
value : Value
span : @moonrockz/diagrams.Span?
} derive(Eq, @moonbitlang/core/debug.Debug)One object member occurrence.
Member::equal
fn Member::equal(Member, Member) -> BoolMember::new
fn Member::new(name : String, value : Value) -> MemberMember::not_equal
fn Member::not_equal(x : Member, y : Member) -> BoolMember::to_repr
fn Member::to_repr(Member) -> @moonbitlang/core/debug.ReprReadResult
pub struct ReadResult {
nodes : Array[@moonrockz/diagrams-plantuml/cst.Node]
document : Document?
diagnostics : ReadOnlyArray[@moonrockz/diagrams.Diagnostic]
}The result of reading a JSON body.
Str
pub struct Str {
text : String
raw : String?
} derive(Eq, @moonbitlang/core/debug.Debug)A JSON string. text is the decoded value. raw is the source spelling
with its quotes, or None for a constructed value. Logical comparison
and canonical writing use only text.
Str::equal
fn Str::equal(Str, Str) -> BoolStr::new
fn Str::new(text : String) -> StrStr::not_equal
fn Str::not_equal(x : Str, y : Str) -> BoolStr::to_repr
fn Str::to_repr(Str) -> @moonbitlang/core/debug.ReprValue
pub struct Value {
kind : ValueKind
span : @moonrockz/diagrams.Span?
} derive(Eq, @moonbitlang/core/debug.Debug)One JSON value with its source span.
Value::array
fn Value::array(items : ArrayView[Value]) -> ValueAn array. The constructor copies items.
Value::boolean
fn Value::boolean(value : Bool) -> ValueValue::equal
fn Value::equal(Value, Value) -> BoolValue::kind_name
fn Value::kind_name(self : Value) -> StringThe kind name of a value: object, array, string, number,
boolean or null.
Value::logical_equal
fn Value::logical_equal(self : Value, other : Value) -> BoolCompare two values without spans and source spellings. The comparison uses an explicit stack, so deep values do not use the call stack.
Value::not_equal
fn Value::not_equal(x : Value, y : Value) -> BoolValue::null
fn Value::null() -> ValueValue::number
fn Value::number(lexeme : String) -> ValueA number with an exact decimal lexeme, for example -0.0 or 1e400.
Writing gives an error when the lexeme is not a valid JSON number.
Value::object
fn Value::object(members : ArrayView[Member]) -> ValueAn object. The constructor copies members.
Value::string
fn Value::string(text : String) -> ValueValue::to_repr
fn Value::to_repr(Value) -> @moonbitlang/core/debug.ReprValueKind
pub(all) enum ValueKind {
Object(ReadOnlyArray[Member])
Array(ReadOnlyArray[Value])
String(Str)
Number(String)
Boolean(Bool)
Null
} derive(Eq, @moonbitlang/core/debug.Debug)The kind and content of one JSON value.
ValueKind::equal
fn ValueKind::equal(ValueKind, ValueKind) -> BoolValueKind::not_equal
fn ValueKind::not_equal(x : ValueKind, y : ValueKind) -> BoolValueKind::to_repr
fn ValueKind::to_repr(ValueKind) -> @moonbitlang/core/debug.ReprValues
diagnostic_codes
let diagnostic_codes : ReadOnlyArray[String]The stable diagnostic codes of the JSON reader, writer and converter.
print_body
fn print_body(document : Document, limits? : @moonrockz/diagrams-plantuml/envelope.Limits) -> Result[String, ReadOnlyArray[@moonrockz/diagrams.Diagnostic]]Write the canonical body of a JSON block: one #highlight line for each
selector, then the value. Every line ends with a line break. The text has
no block markers and no shared statements. On error there is no output.
print_value
fn print_value(value : Value, limits? : @moonrockz/diagrams-plantuml/envelope.Limits) -> Result[String, ReadOnlyArray[@moonrockz/diagrams.Diagnostic]]Write the canonical text of one value: two-space indentation, one member
or element on each line, {} and [] for empty containers. The output
has no trailing line break. Numbers keep their exact lexemes.
read
fn read(scan : @moonrockz/diagrams-plantuml/envelope.Scan, limits? : @moonrockz/diagrams-plantuml/envelope.Limits) -> ReadResultRead the JSON body of a scanned block. The reader keeps every member
occurrence in order, exact number lexemes and decoded strings with their
spellings. It follows the pinned PlantUML profile: a // comment can
stand only before a member name or after a member value; malformed input
is refused with a diagnostic, never coerced.
to_data_tree
fn to_data_tree(document : Document, id? : String, limits? : @moonrockz/diagrams-plantuml/envelope.Limits) -> ConversionConvert a JSON document to a structured-data model. Identities come from
ordered ownership paths: the root value is v, member 2 of the value of
root member 0 is m/0/2 and its value is v/0/2. Names and scalar text
never define identity, so repeated members stay separate.
The model keeps a scalar root and empty root containers as they are.
PlantUML 1.2026.9 draws a scalar root as a one-element array and an empty
root container as an array with one empty string; this library does not
copy that projection. The title is the last title statement.