Arrange JSON instances more like the rest of our code.

Employs the technique of (package) objects extending `*Instances` traits, which generally follows the scalaz model generally followed elsewhere in http4s.
That is a good question. The changes looked fine in spirit, but I noticed
Travis failed, i think in some examples. I'm away from a PC so I'm off
little help debugging.
On Dec 24, 2014 9:11 AM, "Ross A. Baker" <notifications@github.com> wrote:

> In jawn/src/main/scala/org/http4s/jawn/JawnInstances.scala
> <https://github.com/http4s/http4s/pull/149#discussion-diff-22259154>:
>
> > +package jawn
> > +
> > +import _root_.jawn.{AsyncParser, Facade, ParseException}
> > +import jawnstreamz._
> > +
> > +import scalaz.\/-
> > +import scalaz.stream.Process.emit
> > +
> > +trait JawnInstances {
> > +  def jawnDecoder[J](implicit facade: Facade[J]): EntityDecoder[J] =
> > +    EntityDecoder.decodeBy(MediaType.`application/json`) { msg =>
> > +      DecodeResult {
> > +        msg.body.parseJson(AsyncParser.SingleValue).partialAttempt {
> > +          case pe: ParseException =>
> > +            emit(ParseFailure("Invalid JSON", pe.getMessage))
> > +        }.runLastOr(\/-(facade.jstring("fart")))
>
> It does open up a good question: does the empty string parse to JNull or
> is that an error? It's only there to deal with the fact that runLast
> returns an Option.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/http4s/http4s/pull/149/files#r22259154>.
>