Open amnaredo opened 2 years ago
I believe the problem is that Option
deserialization expects an array, so try with:
read[Person]("""{"name": "Joe", "extra": ["Blow"]}""")
Original Author: darkfrog26
Thanks, that makes sense; it explains the error message, expected sequence got string
. Unfortunately, this is wrapping the response of an external API and I can't change the schema.
Original Author: coverbeck
The default pickler (aka upickle.default) will treat options the same way single-element collections are treated, that is as a JSON array.
You can customize the pickler to work with null
s instead, as is described in the docs (example)
Original Author: jodersky
Closing as this is intentional can can be addressed with a custom pickler. Original Author: coverbeck
I have a JSON object where a field may not not be present, that I want to serialize into a case class.
I thought
Option[T]
with a default value is supposed to handle that, but that only works for me if the field is not present. If it's present, I get an exception.Is this supposed to work?
To reproduce
ID: 331 Original Author: coverbeck