circe / circe-yaml

YAML parser for circe using SnakeYAML
Apache License 2.0
141 stars 51 forks source link

String values written quoted when using scala-yaml backend #441

Open OndrejSpanel opened 1 month ago

OndrejSpanel commented 1 month ago
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:

PrintingFolder.onString starts with writer.append('"'), which is understandable, given it is used to produce Json values, which are quoted.