aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Utils/Json.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Utils/Json.elm')
-rw-r--r--src/client/elm/Utils/Json.elm12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/client/elm/Utils/Json.elm b/src/client/elm/Utils/Json.elm
new file mode 100644
index 0000000..29e815b
--- /dev/null
+++ b/src/client/elm/Utils/Json.elm
@@ -0,0 +1,12 @@
+module Utils.Json exposing
+ ( dictDecoder
+ )
+
+import Json.Decode as Decode exposing (Decoder)
+import Dict exposing (Dict)
+
+dictDecoder : Decoder comparable -> Decoder a -> Decoder (Dict comparable a)
+dictDecoder keyDecoder valueDecoder =
+ Decode.map2 (,) keyDecoder valueDecoder
+ |> Decode.list
+ |> Decode.map Dict.fromList