baydet/Pichi

Library for mapping your JSON model to swift application model objects (classes, structs, CoreData objects) and transforming them back to JSON



Documentation

Build Status Carthage compatible

Pichi

This is yet another look on the problem of mapping JSON to your app's model objects. It uses different ideas from

Implementation details

Map

The root part of this library is Map protocol. It declares high level abstraction over JSON. This protocol allows to:

  • access children through subscript
  • returns current JSON raw value with value<T>() method There are also two groups of operators (for JSONBasicConvertable and TransformType protocols) which allows to interact with Map protocol.

FromJSONMap

Implementation of Map protocol based on struct which allows transform raw JSON to your model objects using <-> operators

ToJSONMap

Implementation of Map protocol based on class which allows transform objects to JSON with <-> operators.

JSONBasicConvertable

This protocol is used for simple swift's data types (Int, String, Bool etc.)

TransformType

This protocol is used for tranforming to/from JSON of more complex objects (NSDate, arrays, dictionarys)