HOCON 配置迁移差异检查与 MoonBit 解析
///|
test "typed configuration access reports missing and invalid values" {
let v = @hocon.parse("port=8080\nenabled=true\nhost=localhost")
assert_eq(@hocon.get_int(v, "port"), 8080)
assert_true(@hocon.get_bool(v, "enabled"))
assert_eq(@hocon.get_string(v, "host"), "localhost")
assert_true(
try {
ignore(@hocon.get_int(v, "host"))
false
} catch {
_ => true
},
)
assert_true(
try {
ignore(@hocon.get_bool(v, "missing"))
false
} catch {
_ => true
},
)
}impl ToJson for ConfigNumberpub(all) enum Value {
Text(String)
Bare(String)
Number(String)
Boolean(Bool)
Null
List(Array[Value])
Reference(String)
PathReference(Array[String], Bool)
Object(Map[String, Value])
SealedObject(Map[String, Value])
Concat(Array[(String, Value)])
DelayedMerge(Value, Value)
Bound(Array[String], Int, Value)
Substitution(Array[Array[String]], Bool, Bool, Int)
} derive(Eq, Debug)fn get_duration_list_in(config : Value, key : String, unit : DurationUnit) -> Array[Int64] raise ParseErrorfn[T] get_enum_list(config : Value, key : String, choices : Map[String, T]) -> Array[T] raise ParseErrorfn parse(source : String, includes? : Map[String, String], loader? : (IncludeRequest) -> Result[Array[IncludeSource], String]?, source_name? : String, fallbacks? : Array[String], environment? : Map[String, String]) -> Value raise ParseErrorfn parse_sources(source : IncludeSource, includes? : Map[String, String], loader? : (IncludeRequest) -> Result[Array[IncludeSource], String]?, fallbacks? : Array[IncludeSource], environment? : Map[String, String], object_only? : Bool) -> Value raise ParseErrorfn parse_sources_unresolved(source : IncludeSource, includes? : Map[String, String], loader? : (IncludeRequest) -> Result[Array[IncludeSource], String]?, fallbacks? : Array[IncludeSource], object_only? : Bool) -> Value raise ParseErrorfn parse_unresolved(source : String, includes? : Map[String, String], loader? : (IncludeRequest) -> Result[Array[IncludeSource], String]?, source_name? : String, fallbacks? : Array[String]) -> Value raise ParseErrorfn resolve(config : Value, environment? : Map[String, String], allow_unresolved? : Bool) -> Value raise ParseErrorfn resolve_with(config : Value, source : Value, environment? : Map[String, String], allow_unresolved? : Bool) -> Value raise ParseErrorfn validation_problems(config : Value, reference : Value, paths? : Array[String]) -> Array[ValidationProblem] raise ParseErrorInstall
Download zipHOCON 配置迁移差异检查与 MoonBit 解析