-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbundle_decoding.patch
34 lines (34 loc) · 1.25 KB
/
bundle_decoding.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
10a11
> import org.slf4j.{ Logger, LoggerFactory }
433,435c435,453
< def decodeThis(cursor: HCursor)(implicit params: DecoderParams): Try[Bundle] =
< checkUnknownFields(cursor, otherMetas, refMetas) flatMap (_ =>
< Try(
---
> private val log: Logger = LoggerFactory.getLogger(getClass)
> def decodeThis(cursor: HCursor)(implicit params: DecoderParams): Try[Bundle] =
> checkUnknownFields(cursor, otherMetas, refMetas) flatMap (_ =>
> Try {
> val entries: LitSeq[Entry] =
> if (!params.tolerantBundleDecoding) cursor.decodeAs[LitSeq[Entry]]("entry", Some(LitSeq.empty))
> else
> cursor.downField("entry")
> .arrayCursors
> .getOrElse(Iterable.empty)
> .to(LitSeq)
> .flatMap(j => j.as[Entry] match {
> case Left(l) =>
> log.error(
> s"failed to decode bundle field. Skipping because tolerantBundleDecoding = true. Json was ${j}, Error was:",
> l)
> None
> case Right(x) => Some(x)
> })
368c385
< cursor.decodeAs[LitSeq[Bundle.Entry]]("entry", Some(LitSeq.empty)),
---
> entries,
370c386
< ))
---
> })