scala - Finding the implicit value for Json in play -


when use following code:

import jsonimpl.graphformat val js = json.tojson(g)(graphformat) 

my code compiles , works fine when doesn't work , says: "no json serializer found type sgraph. try implement implicit writes or format type."

import jsonimpl.graphformat val js = json.tojson(g) 

jsonimpl is:

object jsonimpl{     implicit val graphformat = json.format[sgraph] } 

i don't want use companion object sgraph class. problem , why cannot find implicit value?

for sake of completeness: json.format macro, , when you're dealing macros it's idea make sure you're getting appropriately statically typed:

object jsonimpl{   implicit val graphformat: format[sgraph] = json.format[sgraph] } 

in fact idea whenever you're dealing implicit values, , it'll save lot of confusion (sometimes because you've done wrong, , because compiler has).


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -