小编Max*_*ker的帖子

在Elm中解析JSON

我想解析这样的JSON:

{ "shapes":[
{
    "shape": "circle",
    "x": "50",
    "y": "50",
    "r": "40"
},
{
    "shape": "rect",
    "x": "100",
    "y": "100",
    "width": "50",
    "height": "60"
},
]}
Run Code Online (Sandbox Code Playgroud)

这是我的榆树代码:

type alias Model =
    { input : Shape
    , saved : List Shape
    , modal1 : String
    , modal2 : String
    , modal3 : String
    , region : String
    }

type Shape
    = Circle String String String
    | Rectangle String String String String

type Msg
    = LoadJson
    | JsonLoaded (Result Http.Error (List Shape)) …
Run Code Online (Sandbox Code Playgroud)

json web elm

4
推荐指数
1
解决办法
288
查看次数

标签 统计

elm ×1

json ×1

web ×1