---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Work with coders and Codable models

# Work with coders and Codable models {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The iOS implementation of the Mobile SDK provides the additional
functionality of coders and Codable models.

## Coder enumeration {#mobsdk-ios-work-coder-codable_mod__section_fyx_4ly_3qb}

The `Coder` enumeration wraps a `JSONEncoder` with an
accompanying `JSONDecoder` so that both provide the same coding strategy.
Since many of the NowData framework APIs that handle Codable models rely on coding and
decoding from JSON, the `Coder` simplifies and standardizes the way to
specify encoders and decoders. Typically, using the default `Coder`
(`.default`), which encodes and decodes dates using the
`nonISO8601UTC` date formatting, is sufficient. The
`DateFormatter.nonISO8601UTC` is a static date formatter provided by the
NowData framework. It is responsible for encoding and decoding dates that were stored by the
ServiceNow platform in the UTC (GMT+0) time zone, and are used by
the Table API in yyyy-MM-dd HH:MM:SS format,
by taking a device's locale and time zone into consideration.

If custom JSON coding is required, such as when handling specific date formats, you can
create a custom `Coder` by supplying the custom `JSONEncoder`
and `JSONDecoder` as the custom Coder's associated types. Both the encoder
and decoder must use the same coding strategy.

For example:  

    let myEncoder = JSONEncoder()
    myEncoder.dateEncodingStrategy = .formatted(.nonISO8601UTC)
    let myDecoder = JSONDecoder()
    myDecoder.dateDecodingStrategy = .formatted(.nonISO8601UTC)

    let myCoder: Coder = .custom(myEncoder, myDecoder)

## Codable extension for nested structures {#mobsdk-ios-work-coder-codable_mod__section_pvt_3ry_3qb}

The NowData framework provides functionality to decode nested structures by dot-separated
path. This functionality makes it easier to consume nested data by removing the necessity of
using wrapper structure and nested JSON decoding.

