These are chat archives for argonaut-io/argonaut

11th
Apr 2017
Paul Snively
@PaulAtBanno
Apr 11 2017 17:31
Hey, everyone! What do I need to import to get the .asJson syntax?
Or rather, do I need to expose an implicit val in scope if I want that syntax to be available outside a module that does the right import?
I'd like to have my codecs, imports, etc. in one module, then elsewhere just say myFoo.asJson.
Gary Pamparà
@gpampara
Apr 11 2017 17:33
@PaulAtBanno That’s a good question! I’ve never seen that syntax tbh. I just usually use import argonaut._, Argonaut._ and then use .jencode to get the json
I might be using out of date syntax
Paul Snively
@PaulAtBanno
Apr 11 2017 17:33
Hmmm
Colt Frederickson
@coltfred
Apr 11 2017 17:34
scala> import argonaut.JsonIdentity._
import argonaut.JsonIdentity._

scala> "1".asJson
res0: argonaut.Json = "1"
@PaulAtBanno JsonIdentity
If you want to mix that in to another object you're importing you can use object Foo extends argonaut.JsonIdentitys
Paul Snively
@PaulAtBanno
Apr 11 2017 17:36
@coltfred: Heya, thanks!
Colt Frederickson
@coltfred
Apr 11 2017 17:37
@PaulAtBanno np.
Paul Snively
@PaulAtBanno
Apr 11 2017 17:45
OK, more of a dumb implicit/import question: if that same module imports ArgonautShapeless._, how do I expose those implicits outside the module?
I reallllly want to just say import MyCodecs._ in client code, and have automatic case class codec derivation, etc. "just work."
Colt Frederickson
@coltfred
Apr 11 2017 18:03
Sadly, I don't know much about that. If the ArgonautShapeless provides a trait, you could mix that in to MyCodecs?