moon run examples/strict_typesstruct NumericPort {
port : Int32
name : String
} derive(@json.FromJson)
struct TextualPort {
port : String
name : String
} derive(@json.FromJson)== Read by key ==
numeric source get_int -> 5432
string source get_int -> error: key 'db.port': expected Int, got Str
numeric source get_string -> error: key 'db.port': expected Str, got Int
string source get_string -> 5432
== Extract into struct ==
numeric source -> NumericPort port = 5432, name = main
numeric source -> TextualPort error: key 'db.port': expected Str, got Int
string source -> NumericPort error: key 'db.port': expected Int, got Str
string source -> TextualPort port = "5432", name = mainInstall
Download zipMoonBit 原生配置库:一处声明,多来源汇入。