-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add ninny-circe-compat #69
Add ninny-circe-compat #69
Conversation
val objekt = ex1json.to[Example1] | ||
objekt match { | ||
case Failure(e: DecodingFailure) => println(e.printStackTrace()) | ||
} | ||
objekt shouldEqual ex1 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not passing. I'm still trying to figure out. @nrktkt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
objekt
is a Try
and ex1
is an Example1
. so the comparison fails
val objekt = ex1json.to[Example1] | |
objekt match { | |
case Failure(e: DecodingFailure) => println(e.printStackTrace()) | |
} | |
objekt shouldEqual ex1 | |
} | |
val objekt = ex1json.to[Example1] | |
objekt match { | |
case Failure(e: DecodingFailure) => println(e.printStackTrace()) | |
} | |
objekt.success.value shouldEqual ex1 | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the Try is a Failure, i was trying to print the stacktrace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that NinnyToCirce
and CirceToNinny
put toegher, is breaking Circe itself's decoding functionality,
i.e. a Circe json object's Decoder
is implicitly converted to Ninny's FromJson
, then implicitly converted to Decoder
, over and over.
So I think it would be better to separate CirceToNinny
and NinnyToCirce
E.g.
import CirceCompat._
case class Person(name: String, age: Int)
object Person {
implicit val encoder = deriveEncoder[Person]
implicit val decoder = deriveDecoder[Person]
}
val json = Person("alice", 30).asJson
// Decoder[Person] is implicitly converted to FromJson[Person] by CirceCompat
// then FromJson is converted to Decoder, so on so forth
json.to[Person]
d9e61e3
to
a9422a6
Compare
with OptionValues | ||
with TryValues { | ||
|
||
case class Example1(foo: String, bar: Seq[Int]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just add a nested object to these examples and then I think it looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a nested Person
No description provided.