Open DavidDTA opened 2 years ago
I was able to solve the problem with the following diff (against 12.0.0):
diff --git a/src/Firestore/Decode.elm b/src/Firestore/Decode.elm
index 65f643d..920d4f2 100644
--- a/src/Firestore/Decode.elm
+++ b/src/Firestore/Decode.elm
@@ -31,6 +31,7 @@ import Firestore.Types.Geopoint as Geopoint
import Firestore.Types.Reference as Reference
import Iso8601
import Json.Decode as Decode
+import Json.Decode.Extra as ExDecode
import Json.Decode.Pipeline as Pipeline
import Time
@@ -146,7 +147,8 @@ string =
list : Field a -> Field (List a)
list (Field elementDecoder) =
Decode.list elementDecoder
- |> Decode.field "values"
+ |> ExDecode.optionalField "values"
+ |> Decode.map (Maybe.withDefault [])
|> Decode.field "arrayValue"
|> Field
Nice catch!
Can you give me a PR with that diff?
If you write a list of 0 length using the
list
codec and then try to read it back, it fails with the error: