klaxon icon indicating copy to clipboard operation
klaxon copied to clipboard

Supporting a field converter and regular converter

Open SeanOThomas-zz opened this issue 6 years ago • 0 comments

I'm trying to parse class Simple below:

val simple = Klaxon()
                .fieldConverter(DateConverter.KlaxonDate::class, DateConverter())
                .converter(SimpleConverter())
                .parse<Simple>(simpleJson)

Aside from other converting, Simple contains a Date property that needs to be converted (note, Date has its own converter since its occurs as a property in many other classes). The above produce:

Couldn't find a suitable constructor for class Simple to initialize with...

...because the Date property remains a String.

I've also tried the following (without the annotations), which resulted in the same thing:

val simple = Klaxon()
                .converter(DateConverter())
                .converter(SimpleConverter())
                .parse<Simple>(simpleJson)

Thanks for your time in advance. Let me know if I can provide more code.

SeanOThomas-zz avatar Apr 26 '18 15:04 SeanOThomas-zz