Elm-如何将对象的json列表解码为Dict

时间:2019-12-09 12:07:12

标签: json elm

给出对象的JSON列表,例如:

async function loadCommand(command) {
    let TestCommand = await import("./commands/TestCommand.js");
    let test = new TestCommand();
    console.log(test.getName());
}

如何使用[{"id":"1", "name":"Jane"},{"id":"2", "name":"Joe"}] 作为键将其解码为Dict String Foo,其中id是类型Foo的记录? (请注意,记录中还包含ID。)