0

I got stuck in printing(writing) string with Json4s JField.

Simply my situation is like that

case class Sample(
                   name: String,
                   value: String
                   )


val doc = Seq(Sample("name", "John\\s"), Sample("job", "Doctor\\s"), Sample("age", "41\\s"))

What I wanted is to print(write) sample like this

(without escape char, just same as printing "\\s"(code) => "\s"(output))

{"name":"John\d","job":"Doctor\b","age":"41\b"}

What I tried is

val doc = Seq(Sample("name", "John\\s"), Sample("job", "Doctor\\s"), Sample("age", "41\\s"))

val list = doc.map(s=> JField(s.name, s.value)).toList

val jlist = JsonDSL.list2jvalue(list)
println(compact(render(jlist)))

I tried to print with JString or use pretty method instead of compact, but still got string printed with escape char

For example

John\\s

Expected

John\s
Javier Kim
  • 13
  • 3

0 Answers0