How can I map a json with underscore to a camelCase field in a case class?
import org.json4s.jackson.JsonMethods.parse
import org.json4s.DefaultFormats
object Testing {
implicit val formats = DefaultFormats.withBigDecimal
def test = {
val json = parse("""{"some_field":"a value"}""")
json.extract[ThingDTO]
}
}
case class ThingDTO(someField:String)
The error I get:
No usable value for someField Did not find value which can be converted into java.lang.String
snakizeKeys
if you wanted to serialize back to string preserving original case:compact(Extraction.decompose(thing).snakizeKeys)
– Dicrotic