I have the following object which I am serializing to json using Circe
case class Person(name: String, data: String)
val x = Person("test", s"""{"a": 10, "b":"foo"}""")
import io.circe._, io.circe.generic.auto._, io.circe.parser._, io.circe.syntax._
println(x.asJson)
The output of the statement above is
{
"name" : "test",
"data" : "{\"a\":10, \"b\":\"foo\"}"
}
but the output I want is
{
"name": "test",
"data": {
"a": 10,
"b": "foo"
}
}
I get the data for the data field from a json based data store. I want to pass it through (so I don't want to unmarshall it into a scala object, only to demarshall it again into json. that marshall/demarshall is a waste of CPU on my server.
So how do I handle such data?