Protocols

The following protocols are available globally.

  • A protocol that allows you to transform a MapPrimitive (JSON) value to another value. This protocol is used to add more type sypport to the Map class.

    See more

    Declaration

    Swift

    public protocol MapDecoder
  • A protocol that allows you to transform a value into a MapPrimitive (JSON) value. This protocol is used to add more type support to the Map class.

    See more

    Declaration

    Swift

    public protocol MapEncoder
  • A protocol combining both MapEncoder and MapDecoder.

    Declaration

    Swift

    public protocol MapCoder : MapDecoder, MapEncoder where Self.Object == Self.Object, Self.Primitive == Self.Primitive
  • A MapKey is a protocol that provides a parsing mechanism for converting any object (such as a String) into key parts (an array of KeyPart objects). Key parts individually represent a key in a JSON dictionary or position in a JSON array. When combined, key parts represent the nesting structure of a JSON dictionary for a specific value, object or array. The order of key parts matter as they coencide with the nesting order in a dictionary.

    For example, lets say we are given the following key parts: 1 KeyPart.object("first") 2 KeyPart.array("second") 3 KeyPart.object("first")

    This can be used to return the value My Value from the nested key first in the following JSON dictionary:

    {
       "first": {
           "second": [
               {
                   "first": "My Value"
               }
           ]
       }
    }
    

    Using this key when storing a value in the map will, on the other hand, create the above JSON dictionary.

    JSON dictionaries created using key parts are merged when the key part does not represent a leaf in a JSON dictionary.

    For example, if I were to add the value My other value to the above JSON using the following key parts: 1 KeyPart.object("first") 2 KeyPart.array("second") 3 KeyPart.object("second")

    Then i will end up with the following result:

    {
       "first": {
           "second": [
               {
                   "first": "My Value"
                   "second": "My other Value"
               }
           ],
       }
    }
    
    See more

    Declaration

    Swift

    public protocol MapKey
  • A protocol that represents JSON primatives as well as arrays and dictionaries of map primatives.

    WARNING: This protocol should NEVER be used directly as it only adds a form of tagging to primitive variables supported by the Map class. All objects in the map are converted to and from a MapPrimitive object. Adding this protocol to any other object will result in crashes.

    The following objects support MapPrimitive:

    • String
    • Double
    • Bool
    • Int
    • Int8
    • Int16
    • Int32
    • Int64
    • UInt
    • UInt8
    • UInt16
    • UInt32
    • UInt64
    • Array where each Element also conforms to a MapPrimitive
    • Dictionary where each Value also conforms to a MapPrimitive

    Declaration

    Swift

    public protocol MapPrimitive