-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON (proper) #32
Comments
One current issue is that it is quite trivial to derive an encoder which will generate invalid JSON. val tplSchema: Fix[Schema, (Boolean, String)] = prim(JsonSchema.JsonBool) :*: prim(JsonSchema.JsonString)
implicit val primToEncoderNT = new (Prim ~> Encoder) {
def apply[A](fa: Prim[A]): Encoder[A] = { a =>
fa match {
case JsonNumber => a.toString
case JsonBool => a.toString
case JsonString => s""""$a""""
case JsonNull => "null"
}
}
}
val serializer: Encoder[(Boolean, String)] = tplSchema.to[Encoder]
val out = serializer((true, "asdf"))
Fail.string(out) will output the problem here is that there is no "sensible" encoder for an anonymous tuple. So far I see 2 possibilities to rectify this:
both of there would require a more powerful fold than |
@vil1 I would like to work on schema module for Circe library if you have not started on it. |
We currently have a toy example interpreting schemas into JSON encoders, that merely stands as an example/POC for interpreting schemas into contravariant functors.
We need to add modules for working real-world JSON libraries (prioritising the most widely used).
Candidates are:
The text was updated successfully, but these errors were encountered: