我试图学习ReasonML,并遵循bs json的示例,我们可以将原始json解码为如下类型:
type point = { x: float, y: float }; module Decode = { let point = json => Json.Decode.{ x: json |> field("x", float), y: json |> field("y", float) }; }
我有点搞不懂这是怎么回事 Json.Decode.{ ... } .()
Json.Decode.{ ... }
.()
它的意思几乎是一样的 Json.Decode {} ,它像往常一样定义了一个记录。基本上只是对 Json.Decode.({ .. })
Json.Decode
{}
Json.Decode.({ .. })
编辑:我刚刚给你的博客添加了一条注释 bs-json 下面是自述 the example
bs-json