bizzabo / play-json-extensions

+22 field case class formatter and more for play-json
http://cvogt.org/play-json-extensions/api/
Other
196 stars 44 forks source link

Build failed with play-json 2.4.0-RC1 #2

Closed djx314 closed 9 years ago

djx314 commented 9 years ago

When I checkout the master and change

"com.typesafe.play" %% "play-json" % "2.3.4",

to

"com.typesafe.play" %% "play-json" % "2.4.0-RC1",

and test. But it compile failed.

[error] ******/play-json-extensions-0.2/src/test/scala/CaseClassTest.scala:45: No Json deserializer found for type Option[String]. Try to implement an implicit Reads or Format for this type.
[error] Error occurred in an application involving default arguments.
[error]     implicit def fmt1 = Jsonx.formatCaseClass[Bar]
[error]                                              ^
[error] one error found
[error] (test:compile) Compilation failed
[error] Total time: 4 s, completed 2015-5-1 17:06:27

And in play-json 2.3.8 it builds successed.

cvogt commented 9 years ago

Thx! I'll check it out in a week or two. Busy right now.

dsferruzza commented 9 years ago

I guess it has something to do with https://playframework.com/documentation/2.4.x/Migration24#Reading-Options

It looks like you can use the removed OptionReads from https://github.com/playframework/playframework/commit/4fa5d3b2e4e9edf66dcfc51a9e15af3c19f08268, but it's not ideal...

cvogt commented 9 years ago

Asked @jroper on twitter, what he recommends: https://twitter.com/cvogt/status/605735633252970496

You are right about the change being the problem, but the guide doesn't describe a solution for arbitrary structures containing Options in multiple arbitrary places. That would be a problem for many people I suppose. They probably have a solution in store, but not documented.

gilbertw1 commented 9 years ago

+1

Migrating to 2.4 and this caused me a lot of trouble and I ended up solving it by using the removed OptionReads, which feels really bad to me. However, I guess it'll work until a better solution is provided.

analytically commented 9 years ago

+1

cvogt commented 9 years ago

published 0.3.0-SNAPSHOT for play-json 2.4.1. please try if it works for you guys.

0.3.0 also comes with extension methods for JsValue and JsLookupResult validateAuto that automatically uses validate or validateOpt as appropriate, validateOpt that handles options (will be built in play-json in the next release)

cvogt commented 9 years ago

fixed in release 0.3.0

To use options in your code use

import org.cvogt.test.play.json.implicits.optionWithNull // play 2.4 suggested behavior

or

import org.cvogt.test.play.json.implicits.optionNoError // play 2.3 behavior
dsferruzza commented 9 years ago

0.3.0 seems to work! Thanks!