我正在尝试将以下 JSON 对象解码为 Reason 对象。
{"AAPL":{"price":217.36}}
对象根中的键是动态的。
以下一般示例在密钥不在根目录中时有效。我将如何更改它以使其适用于根目录中的动态键?
module Decode = {
let obj = json =>
Json.Decode.{
static: json |> field("static",string),
dynamics: json |> field("dynamics", dict(int)),
};
};