Skip to content

Commit

Permalink
Merge pull request #8 from bhudgeons/nonulls
Browse files Browse the repository at this point in the history
Default encoder now excludes Option.None instead of "key":null
  • Loading branch information
jeremyrsmith committed Mar 10, 2016
2 parents ade8916 + cfcd5fd commit feb302e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import shapeless.Witness

package object circe {

private val printer = Printer.noSpaces.copy(dropNullKeys = true)

implicit def circeEncoder[A : Encoder] : content.Encoder[A, Witness.`"application/json"`.T] =
content.Encoder.of("application/json") {
(value: A, charset: Charset) => content.Encoder.encodeString(value.asJson.toString, charset)
(value: A, charset: Charset) => content.Encoder.encodeString(printer.pretty(value.asJson), charset)
}

implicit def circeDecoder[A : Decoder] : content.Decoder.Aux[Witness.`"application/json"`.T, A] =
Expand Down

0 comments on commit feb302e

Please sign in to comment.