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.

Source

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.

Source

Document::equal

fn Document::equal(Document, Document) -> Bool

Source

Document::logical_equal

fn Document::logical_equal(self : Document, other : Document) -> Bool

Compare two documents without spans and source spellings.

Source

Document::new

fn Document::new(value : Value, name? : String, statements? : ArrayView[@moonrockz/diagrams-plantuml/envelope.Statement], highlights? : ArrayView[@moonrockz/diagrams-plantuml/data.Selector]) -> Document

A document. The constructor copies its arrays.

Source

Document::not_equal

fn Document::not_equal(x : Document, y : Document) -> Bool

Source

Document::to_repr

fn Document::to_repr(Document) -> @moonbitlang/core/debug.Repr

Source

Member

pub struct Member {
  name : Str
  value : Value
  span : @moonrockz/diagrams.Span?
} derive(Eq, @moonbitlang/core/debug.Debug)

One object member occurrence.

Source

Member::equal

fn Member::equal(Member, Member) -> Bool

Source

Member::new

fn Member::new(name : String, value : Value) -> Member

Source

Member::not_equal

fn Member::not_equal(x : Member, y : Member) -> Bool

Source

Member::to_repr

fn Member::to_repr(Member) -> @moonbitlang/core/debug.Repr

Source

ReadResult

pub struct ReadResult {
  nodes : Array[@moonrockz/diagrams-plantuml/cst.Node]
  document : Document?
  diagnostics : ReadOnlyArray[@moonrockz/diagrams.Diagnostic]
}

The result of reading a JSON body.

Source

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.

Source

Str::equal

fn Str::equal(Str, Str) -> Bool

Source

Str::new

fn Str::new(text : String) -> Str

Source

Str::not_equal

fn Str::not_equal(x : Str, y : Str) -> Bool

Source

Str::to_repr

fn Str::to_repr(Str) -> @moonbitlang/core/debug.Repr

Source

Value

pub struct Value {
  kind : ValueKind
  span : @moonrockz/diagrams.Span?
} derive(Eq, @moonbitlang/core/debug.Debug)

One JSON value with its source span.

Source

Value::array

fn Value::array(items : ArrayView[Value]) -> Value

An array. The constructor copies items.

Source

Value::boolean

fn Value::boolean(value : Bool) -> Value

Source

Value::equal

fn Value::equal(Value, Value) -> Bool

Source

Value::kind_name

fn Value::kind_name(self : Value) -> String

The kind name of a value: object, array, string, number, boolean or null.

Source

Value::logical_equal

fn Value::logical_equal(self : Value, other : Value) -> Bool

Compare two values without spans and source spellings. The comparison uses an explicit stack, so deep values do not use the call stack.

Source

Value::not_equal

fn Value::not_equal(x : Value, y : Value) -> Bool

Source

Value::null

fn Value::null() -> Value

Source

Value::number

fn Value::number(lexeme : String) -> Value

A 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.

Source

Value::object

fn Value::object(members : ArrayView[Member]) -> Value

An object. The constructor copies members.

Source

Value::string

fn Value::string(text : String) -> Value

Source

Value::to_repr

fn Value::to_repr(Value) -> @moonbitlang/core/debug.Repr

Source

ValueKind

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.

Source

ValueKind::equal

fn ValueKind::equal(ValueKind, ValueKind) -> Bool

Source

ValueKind::not_equal

fn ValueKind::not_equal(x : ValueKind, y : ValueKind) -> Bool

Source

ValueKind::to_repr

fn ValueKind::to_repr(ValueKind) -> @moonbitlang/core/debug.Repr

Source

Values

diagnostic_codes

let diagnostic_codes : ReadOnlyArray[String]

The stable diagnostic codes of the JSON reader, writer and converter.

Source

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.

Source

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.

Source

read

fn read(scan : @moonrockz/diagrams-plantuml/envelope.Scan, limits? : @moonrockz/diagrams-plantuml/envelope.Limits) -> ReadResult

Read 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.

Source

to_data_tree

fn to_data_tree(document : Document, id? : String, limits? : @moonrockz/diagrams-plantuml/envelope.Limits) -> Conversion

Convert 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.

Source