Reputation: 33
I have a case class with two fields like the following:
case class Data {
a: String
b: String
}
The values of both a and b are complex JSON strings.
When I am trying to do compact(render(data))
I am getting json with newlines and double quotes. Pasting a sample output
{"a":"\n{\"A29ebM5zRGu0UU1xNnfoCeQP\":{\"entity\":{\"timestamp\":\"2024-06-22T00:07:58.806Z\",\"_aep_stage_va6_appliedml\":{\"userid\":\"58874485546249370541145051099296067917\"},\"_id\":\"00031af8-cd81-4a95-b5a8-7bb13a419ea8\",\"directMarketing\":{\"clicks\":null,\"emailDelivered\":{\"value\":1.0},\"emailVisitorID\":\"[email protected]\",\"hashedEmail\":\"809rzuGYiM\",\"messageID\":\"5ff74428-65de-448c-9b4e-fee235e3a9fc\",\"offerOpens\":null,\"opens\":null,\"sends\":{\"value\":1.0}},\"eventMergeId\":null,\"eventType\":\"directMarketing.emailSent\",\"producedBy\":\"databricks-synthetic\",\"web\":null}}}\n"}
The output I am expecting is simple json without any newlines and escape characters for double quotes in a and b.
What could be the cleanest way to get the same?
Upvotes: 0
Views: 25