uk.gov.hmrc.play

# json

#### package json

Visibility

1. Public
2. All

### Type Members

1. #### class Enum[B] extends AnyRef

2. #### class EnumMapping[B] extends Mapping[String, B]

3. #### class Mapping[A, B] extends AnyRef

### Value Members

1. #### object Mappings

   Usage examples:

   Usage examples:

   Constructor that never fails:

       case class Foo(value: String)

       object Foo extends (String => Foo) {

         private val mapping = Mappings.map[String, Foo](Foo, _.value)

         implicit val jsonFormat = mapping.jsonReads

         implicit val pathBindable = mapping.pathBindable

         implicit val queryStringBindable = mapping.queryStringBindable

       }

   Constructor that may fail:

       case class Bar(value: String) {
         require(value.nonEmpty)
       }

       object Bar {

         private val mapping = Mappings.mapTry[String, Foo](s => Try(Foo(s)), _.value)

         implicit val jsonFormat = mapping.jsonReads

         implicit val pathBindable = mapping.pathBindable

         implicit val queryStringBindable = mapping.queryStringBindable

       }

   Enumeration:

       sealed trait Base
       case object Thing1 extends Base
       case object Thing2 extends Base

       object Base {

         private val mapping = Mappings.mapEnum(Thing1, Thing2)

         def fromString(name: String): Option[Base] = mapping.fromString(name)

         implicit val jsonFormat = mapping.jsonReads

         implicit val pathBindable = mapping.pathBindable

         implicit val queryStringBindable = mapping.queryStringBindable

       }

### Ungrouped