import io.circe.generic.semiauto._
import io.circe.syntax._
import io.circe._
import io.circe.yaml._
import io.circe.yaml.scalayaml.Printer
case class V(string: String)
object V {
implicit val vEncoder: Encoder[V] = deriveEncoder
}
val v = V("hello world")
val yamlString = Printer.pretty(v.asJson)
println(yamlString)
Result is string: "hello world" instead of expected string: hello world.
The quotes are there because of jsonToNode last case:
case json =>
Node.ScalarNode(json.toString)
Here json.toString calls:
spaces2
Printer.spaces2.print(this)
unsafePrintToAppendable
foldWith
folder.onString
PrintingFolder.onString starts with writer.append('"'), which is understandable, given it is used to produce Json values, which are quoted.
Result is
string: "hello world"
instead of expectedstring: hello world
.The quotes are there because of
jsonToNode
last case:Here
json.toString
calls:spaces2
Printer.spaces2.print(this)
unsafePrintToAppendable
foldWith
folder.onString
PrintingFolder.onString
starts withwriter.append('"')
, which is understandable, given it is used to produce Json values, which are quoted.