A bounded MoonBit Amazon Ion 1.0 value-stream codec with text and binary decoding, deterministic encoding, ordered structs, annotations, symbols, and resource limits.
| 包 | 作用 |
|---|---|
| format_model | Ion 值、symbol、decimal、timestamp、限制和错误模型 |
| decode | 文本扫描解析与二进制读取 |
| encode | 文本写出与二进制写出 |
| 根包 | 对常用 parse/encode 操作的简短转发 API |
| fixtures | 小型有效样例与覆盖说明 |
| maintenance | 规范、互操作性和工具链维护记录 |
import { "LL124-Arch/amazon-ion-moonbit-core" @ion }
let values = @ion.parse_text("{answer: 42, enabled: true}")
let binary = @ion.encode_binary(values[:])
let decoded = @ion.parse_binary(binary)
let text = @ion.encode_text(decoded[:])import {
"LL124-Arch/amazon-ion-moonbit-core/format_model" @ion,
"moonbitlang/core/bigint",
}
let value = @ion.IonValue::int(
@bigint.BigInt::from_string("123456789012345678901234567890"),
).with_annotations([@ion.IonSymbol::from_text("id")])
match value.as_int() {
Some(identifier) => println(identifier.to_string())
None => println("expected an Ion int")
}import {
"LL124-Arch/amazon-ion-moonbit-core" @ion,
"LL124-Arch/amazon-ion-moonbit-core/format_model" @model,
}
let values = @ion.parse_text("{name: \"ion\"}")
let stats = @ion.preflight_values(
values[:],
limits=@model.Limits::new(max_depth=8, max_text_bytes=1024),
)
println("values: \{stats.value_count()}")
let limit_error = try @ion.preflight_values(
values[:],
limits=@model.Limits::new(max_values=0),
) catch {
error => error
} noraise {
_ => fail("expected configured limit")
}
match limit_error.limit_kind() {
Some(kind) => println("budget exceeded: \{to_repr(kind)}")
None => println(limit_error.summary())
}moon fmt --check
moon check
moon test
moon test --target native
moon test --target wasm
moon test --target wasm-gc
moon test --target js
moon build --target native
moon build --target wasm
moon build --target js
moon doc --quietcd roundtrip_lab
npm ci
node ion-js-diff.mjsfn binary_version(input : Bytes) -> (Int, Int)?fn diagnose_text_binary(text : String, binary : Bytes, limits? : Limits) -> InteropReport raise IonErrorfn encode_hex(input : Bytes) -> Stringfn is_binary(input : Bytes) -> Booltest {
let values = [@model.IonValue::string("ion")]
let stats = preflight_values(
values[:],
limits=@model.Limits::new(max_text_bytes=3),
)
assert_eq(stats.value_count(), 1)
}fn reencode_binary_range(input : Bytes, start : Int, length : Int, input_limits? : Limits, options? : EncodeOptions) -> Bytes raise IonErrorfn reencode_text_range(input : String, start : Int, length : Int, input_limits? : Limits, options? : EncodeOptions) -> String raise IonErrorInstall
Download zipA bounded MoonBit Amazon Ion 1.0 value-stream codec with text and binary decoding, deterministic encoding, ordered structs, annotations, symbols, and resource limits.