Clarifying nested object conversion
See original GitHub issueI’m trying to understand how I can achieve the following:
sealed trait TC
case class ITC(count:Int, work:TC) extends TC
case class SSTC(query:String, args:List[AnyRef]) extends TC
case class Global(work:List[TC], runtime:Option[FiniteDuration)
I can’t seem to understand the process that would be required to achieve something like this. I get the exception listed in the documentation (i.e could not find implicit value for parameter conv: pureconfig.ConfigConvert[Global]
) but I can’t for the life of me figure out what’s causing it or what steps I can use to fix it.
I’ve tried to create a custom converter, but I’m not sure how to leverage pureconfig to load the types it already knows about.
Issue Analytics
- State:
- Created 7 years ago
- Comments:9
Top Results From Across the Web
How to simplify conversion of nested object into array of objects?
Try following. let arr = [{"children":[{"children":[{"children":[],"Id":1,"Name":"A","Image":"http://imgUrl"}],"Id":2,"Name":"B" ...
Read more >Flat JSON To Nested Objects | Swift 4, Xcode 10 - YouTube
Today go over how to convert flat JSON (non- nested ) into nested Swift objects with Decodable/Codable. Following this approach will make you ......
Read more >Converting types of keys of nested object to respective CSS ...
Converting types of keys of nested object to respective CSS key type. Give an object which would look something like:
Read more >How to handle a bunch of nested ValueObjects?
Currently the objects provide long constructors, that get a structured array data passed in and convert / map it to their plain properties...
Read more >Map and object: converting nested objects - Xul.fr
Map and object: converting nested objects ... When we want to save the contents of a JavaScript Map structure in a file, we...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The error means that pureconfig cannot find the
ConfigConvert
instance for one or more types inGlobal
and consequently it cannot derive theConfigConvert
forGlobal
itself. Now the question is which type. There is a way to check the type by using a scala console. Basically you can check every type until you get an errorThe issue is that
AnyVal
doesn’t have aConfigConvert
because it’s anabstract class
and not a sealed family. The good news is thatAnyVal
contains all types that can easily be converted from/to String and it should be easy to implement aConfigConverter
for it. Scala defines nine types that are subclasses ofAnyVal
, which areDouble
,Float
,Long
,Int
,Char
,Short
,Byte
,Unit
andBoolean
. pureconfig hasConfigConvert
instances forDouble
,Float
,Long
,Int
,Short
andBoolean
. You can either decide to ignore the remaining types, which areChar
,Byte
andUnit
, or createConfigConvert
for them. It’s up to you but here I’m going to ignore them and show how to create theConfigConvert
ofAnyVal
from existingConfigConvert
instances for the subclasses. The code that I’m going to use can be enhanced with the missingConfigConvert
instances. The code forAnyVal
would be:Now that there is an instance of
ConfigConvert
forAnyVal
, pureconfig can deriveGlobal
:@melrief What workaround has been found for this? Im having the same issue. My Nested Case Classes is not compiling. Its not related to AnyVal.