Package

org.coursera.naptime

courier

Permalink

package courier

Visibility
  1. Public
  2. All

Type Members

  1. class StringKeyCodec extends DataCodec

    Permalink

    Intended for Legacy support only!

    Intended for Legacy support only!

    This should only be used where compatibility with StringKeyFormat is required, for all other uses, please see the more flexible InlineStringCodec.

    Provides an codec for Pegasus data that is compatible with StringKeyFormat.

    While this codec encodes data in the same format as StringKeyFormat, it is designed to be used with Courier, not with Play JSON Formats.

    Limitations: - The pegasus bytes type is not supported, consider base64 encoding to a string instead - The pegasus union type is not supported, please migrate to InlineStringCodec if needed - The pegasus map type is not supported, please migrate to InlineStringCodec if needed - Records containing optional fields are not allowed

    This codec is "schema aided", meaning that the correct Pegasus schema is required to serialize or deserialize data, even to the raw DataMap and DataList types. This is because the order and names of record fields, defined in the schema, must be used by the codec to correctly serialize/deserialize to StringKeyFormat tuples.

    The important type relations are:

    StringKeyFormat type | Pegasus raw type | Pegasus schema type | Scala type ---------------------|------------------|---------------------|---------------------------------- Tuple | DataMap | record | case class <TypeName> Seq | DataList | array | <ItemName>Array extends IndexedSeq[T]

    The "Tuple" encoding --------------------

    - Example: [email protected] - JSON Equivalent: { "email": "[email protected]", "message": "Greetings", "recipient": "John"} - Reserved chars: !~ - Escape char: !

    StringKeyFormat tuples are positionally ordered. The order of the tuple values must match the order of fields in a pegasus record. E.g. the pegasus record:

    {
      "name": "...",
      "type": "record",
      "fields": [
        { "name": "message", "type": "..." },
        { "name": "recipient", "type": "..." },
        { "name": "email", "type": "..." }
      ]
    }

    Would be required for the above tuple example.

    An empty string is parsed to a tuple of size 1 containing a single empty string.

    The "Seq" encoding ------------------

    - Example: one~two~three - JSON Equivalent: [ "one", "two", "three" ] - Reserved chars: !, - Escape char: !

    An empty string is parsed to an empty Seq.

Value Members

  1. object CourierFilters

    Permalink

    Courier related data filters.

  2. object CourierFormats extends StrictLogging

    Permalink

    Provides utilities for converting between courier and Play JSON.

  3. object CourierImplicits

    Permalink

    Courier related implicit helpers.

  4. object CourierSerializer

    Permalink

    Provides methods for serializing and deserializing the Pegasus data types used by Courier to JSON.

    Provides methods for serializing and deserializing the Pegasus data types used by Courier to JSON.

    This uses TypedDefinitionCodec, the default codec for use with Courier at Coursera.

    For example, given a generated Courier data binding class named Profile, to serialize the Courier data binding class (a.k.a. data template) to JSON:

    val profile = Profile(...) val jsonString = CourierSerializer.write(profile)

    And to Deserialize JSON to the Courier data binding:

    val profile = CourierSerializer.read[Profile](jsonString)

  5. object SchemaInference

    Permalink

    Infers or extracts Pegasus schemas for Scala types.

  6. object StringKeyCodec

    Permalink
  7. object TypedDefinitions

    Permalink

    Convenience methods for working with Typed Definitions.

Ungrouped