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