-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customization for Json macros #7
Comments
One need I have is a reader which handles case class Xyz(foo: Int, bar: Option[String], baz: Option[Int])
implicit val xyzReader = Json.reads[Xyz]
val json = Json.parse("""{"foo": 123, "bar": null}""")
val result = json.as[Xyz]
//expected result is Xyz(123, Some(null), None) Using To my knowlegde this is not currently possible, but I may be wrong. Could I use some of the macro infrastructure from the current play release, to write such a macro myself? |
+1 for allowing the usage of default values in Reads impls, specifically in the case for deserializing non-existent collections as an empty of that collection. E.g., would love to replace a lot of |
I am also interested in doing with @roti mentioned above. This is especially important with HTTP I have opened a discussion about this here: https://discuss.lightbend.com/t/distinguishing-between-omitted-and-null-values/7105 |
(Moved from playframework/playframework#4684)
As more people start using the json macros, a lot of people seem to want to customize features slightly. We should come up with a general strategy for doing this. Ideally it should be possible to use several of these customizations at once.
Here are a few features we might want to customize:
Reads
implementation (see Make Json.reads macro handle case class default params gracefully #4)When it comes to the behavior for things like property naming and default values, it should also be easy to use the same conventions across your application.
The text was updated successfully, but these errors were encountered: