我想解析这样的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)