You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've been wanting to update to json4s 3.7.x or 4.x for quite some time, but are currently blocked by the way strictOptionParsing is implemented as of #688 .
We use json4s together with akka-http and elastic4s.
In our customer-facing API:
We don't want to require our customers to spell out all optional properties that they don't use
We want to return a BadRequest if they provide an incorrect enum value (we use enumeraturm), for instance sipped instead of shipped
When retrieving data from Elasticsearch:
If an optional field is added; it should default to None for existing records (that don't have this field), due to Backwards Compatibility
The behavior we seek:
When an optional field is not provided, it should default to None
When an optional field is provided but an invalid value is provided: throw an exception.
This is the behavior in 3.6.12 when using withStrictOptionParsing, however as of 3.7 and above:
using withStrictOptionParsing requires to write out all optional fields
not using withStrictOptionParsing allows you to provide an incorrect value for an optional field.
I was wondering if you'd appreciate a PR for a patch for when strictOptionParsing = false to change the behavior to what is described above.
Hi there,
We've been wanting to update to json4s 3.7.x or 4.x for quite some time, but are currently blocked by the way
strictOptionParsing
is implemented as of #688 .We use
json4s
together withakka-http
andelastic4s
.In our customer-facing API:
sipped
instead ofshipped
When retrieving data from Elasticsearch:
None
for existing records (that don't have this field), due to Backwards CompatibilityThe behavior we seek:
None
This is the behavior in 3.6.12 when using
withStrictOptionParsing
, however as of 3.7 and above:withStrictOptionParsing
requires to write out all optional fieldswithStrictOptionParsing
allows you to provide an incorrect value for an optional field.I was wondering if you'd appreciate a PR for a patch for when
strictOptionParsing = false
to change the behavior to what is described above.Example of parsing an
Option[BigDecimal]
:None
null
None
12.5
Some(12.5)
"Hello there"
json4s version
3.6.12
scala version
2.13.10
jdk version
openjdk 11.0.17 2022-10-18
Minimal example
Generated output:
The text was updated successfully, but these errors were encountered: