【文件属性】:
文件名称:elm-json-decode-pipeline:使用管道在Elm中构建JSON解码器
文件大小:8KB
文件格式:ZIP
更新时间:2021-05-15 07:47:45
Elm
json-decode-pipeline
使用管道运算符构建JSON解码器。
动机
解码为具有type alias的记录是很常见的。 这是来自 docs的示例:
type alias Job = { name : String , id : Int , completed : Bool }
point : Decoder Job
point =
map3 Job
( field " name " string )
( field " id " int )
( field " completed " bool )
之所以可行,是因为可以将记录类型别名称为普通函数。 在这种情况下,它为每个字段接受一个参数(以任何顺序在类型别名中声明字段),然后返回使用这些参数构建的适当记录。
mapN解码器很简单,但是每当字段计数更改时,都需要手动更改N。 该库提供旨在与
【文件预览】:
elm-json-decode-pipeline-master
----src()
--------Json()
----elm.json(492B)
----examples()
--------Example.elm(445B)
----LICENSE(1KB)
----README.md(3KB)
----tests()
--------.gitignore(12B)
--------Tests.elm(4KB)
----.gitignore(80B)