Data
-
DataInputFrom TealiumPrismCoreDataInputis a protocol used to limit the type of data that can be sent to Tealium to later serialize it into JSON.Warning
Do not conform custom types to theDataInputprotocol or it will defeat the purpose of this protocol.Converting a custom object to a
DataInputcan be done easily by adopting theDataInputConvertibleprotocol and implementing theDataInputConvertible.toDataInput()method for a safe conversion.Valid
DataInputcan only be:- a String
- a Number: Int, Int64, Double, Float, Decimal, NSNumber
- a Bool
an Array or Dictionary containing only Strings, Numbers or Booleans or other nested Arrays and Dictionaries containing other valid
DataInput
Warning
Non conforming floats like
Double.nanorFloat.infinitywill be silently converted to strings “NaN” and “Infinity” (or “-Infinity” for negative “Infinity”) upon serialization inside of the library.Declaration
Swift
public protocol DataInput -
Use this protocol to convert custom types to a valid
DataInput.This is particularly useful for types like enums or objects that can be safely represented with a Dictionary or an Array or a combination of nested Dictionaries and Arrays. Everything that is not a Dictionary or an Array, including the elements contained in those collections, need to be one of the supported
DataInput.For cases in which you have only nested Arrays and Dictionaries that only contain valid
DataInput, implementing this protocol is not necessary and you can just wrap them with the prebuiltDataItemwrapper.Although not preferable, you can make any
See moreEncodabletype aDataInputConvertibleby wrapping it withDataItem(serializing:). Note that this method can fail, so you must handle the eventualEncodingErrorthat can be thrown in case of failure.Declaration
Swift
public protocol DataInputConvertible -
A wrapper class that contains a generic JSON value.
You can use the utility getters to obtain the value in the correct type:
- You can read any number as Int/Float/Double/NSNumber intercheangebly since it’s backed by an NSNumber on disk.
Arrays and Dictionaries will always contain
DataItemas values and you can use specific getter to get the correct types from them too.
Warning
Do NOT cast this wrapper class to anything else as it will fail. Use the appropriate conversion methods instead.
Mistake example:
See morelet numbers: [Int?]? = DataItem(value: [1, 2, 3]).getDataArray() as? [Int?] // Cast will fail and numbers will be nil let numbers: [Int?]? = DataItem(value: [1, 2, 3]).getArray() // This will succeed let numbers: [Int?]? = DataItem(value: [1, 2, 3]).getDataArray().map { $0.getInt() } // This will also succeed let numbers: [Int]? = DataItem(value: [1, 2, 3]).getArray().compactMap { $0 } // This will also succeed and remove potentially nil values from the arrayDeclaration
Swift
final public class DataItemextension DataItem: DataInputConvertibleextension DataItem: Decodable -
Classes that implement this protocol should be able to reconstruct an object of type
See moreConvertiblefrom a givenDataItem, on the assumption that theDataItemaccurately describes all components required to create a new instance of typeConvertible.Declaration
Swift
public protocol DataItemConverter<Convertible> -
Declaration
Swift
public protocol DataItemExtractor : JSONPathExtractable where Self.Root == ObjectRoot -
A custom wrapper around a common Dictionary used to limit the
DataInputtypes into the Dictionary.Only valid
See moreDataInputtypes will be stored in the inner Dictionary and onlyDataInputConvertibletypes can be used to initialize this wrapper object.Declaration
Swift
public struct DataObject : ExpressibleByDictionaryLiteralextension DataObject: Codableextension DataObject: DataItemExtractorextension DataObject: DataInputConvertibleextension DataObject: CustomStringConvertibleextension DataObject: Equatable -
Use this protocol to convert custom types to their
See moreDataObjectrepresentation.Declaration
Swift
public protocol DataObjectConvertible : DataInputConvertible -
Generic data storage for storing
DataInputand retrievingDataItemobjects.Implementations are not guaranteed to be persistent. For instance, in cases where there may be insufficient storage space on the device, or other reasons such as write permissions etc.
Stored data requires an
See moreExpiryto be provided when storing, and expired data will not be included in any retrieval operations; that is, expired data won’t be returned bygetorgetAllbut it will also not be included in any aggregate methods such askeysorcount.Declaration
Swift
public protocol DataStore : AnyObject, DataItemExtractor -
A data store edit for a specific key
See moreDeclaration
Swift
public enum DataStoreEdit -
Enables editing multiple entries in the module storage in a transactional way.
See moreDeclaration
Swift
public protocol DataStoreEditor -
Errors that can occur during database operations.
See moreDeclaration
Swift
public enum DatabaseError : ErrorEnum, ErrorWrapping -
The expiration type of some persisted value.
See moreDeclaration
Swift
public enum Expiry : Equatable -
Represents a tracking event or view to be dispatched.
See moreDeclaration
Swift
public struct Dispatch -
Context with information around the track that generated the Dispatch request.
See moreDeclaration
Swift
public struct DispatchContext -
The type of dispatch being sent.
See moreDeclaration
Swift
public enum DispatchType : String -
JSONArrayPathFrom TealiumPrismCoreA
JSONPaththat can be applied to a JSON array to represent the path to a potentially nested value. Nested items can be in both JSON objects and JSON arrays.To create a path like
[0].container.array[0].propertyyou can use a subscript for each path component:JSONPath[0]["container"]["array"][0]["property"] -
JSONObjectPathFrom TealiumPrismCoreA
JSONPaththat can be applied to a JSON object to represent the path to a potentially nested value. Nested items can be in both JSON objects and JSON arrays.To create a path like
container.array[0].propertyyou can use a subscript for each path component:JSONPath["container"]["array"][0]["property"]Declaration
Swift
public typealias JSONObjectPath = JSONPath<ObjectRoot> -
A structure representing the location of an item in a JSON object or JSON array, potentially nested in other JSON objects and JSON arrays.
To create a basic
JSONPathyou can call theJSONPathsubscript with aStringor anIntdepending on where you want to start the path from: the first one would start from a JSON object, the second would start from a JSON array.let objectPath = JSONPath["container"] let arrayPath = JSONPath[0]To create a path like
container.array[0].propertyyou can use a subscript for each path component:
See moreJSONPath["container"]["array"][0]["property"]Declaration
-
ArrayRootFrom TealiumPrismCore -
ObjectRootFrom TealiumPrismCore -
PathRootFrom TealiumPrismCoreAn internal protocol used to differentiate between
ObjectRootandArrayRoot. Do not adopt this protocol in other types.Declaration
Swift
public protocol PathRoot -
A container for a reference to a variable in the data layer.
See moreDeclaration
Swift
public struct ReferenceContainer : Equatableextension ReferenceContainer: DataObjectConvertible -
A container for a string value
See moreDeclaration
-
Declaration
-
A type-erased
Codablevalue.The
AnyCodabletype forwards encoding and decoding responsibilities to an underlying value, hiding its specific underlying type.You can encode or decode mixed-type values in dictionaries and other collections that require
EncodableorDecodableconformance by declaring their contained type to beAnyCodable.See also
AnyEncodableSee moreSee also
AnyDecodableDeclaration
Swift
public struct AnyCodable : Codableextension AnyCodable: CustomStringConvertibleextension AnyCodable: CustomDebugStringConvertible -
A type-erased
Decodablevalue.The
AnyDecodabletype forwards decoding responsibilities to an underlying value, hiding its specific underlying type.You can decode mixed-type values in dictionaries and other collections that require
Decodableconformance by declaring their contained type to beAnyDecodable:let json = “”“ { "boolean”: true, “integer”: 1, “double”: 3.14159265358979323846, “string”: “string”, “array”: [1, 2, 3], “nested”: { “a”: “alpha”, “b”: “bravo”, “c”: “charlie” } } “”“.data(using: .utf8)!
let decoder = JSONDecoder() let dictionary = try! decoder.decode([String: AnyCodable].self, from: json)
See moreDeclaration
Swift
public struct AnyDecodable : Decodableextension AnyDecodable: CustomStringConvertibleextension AnyDecodable: CustomDebugStringConvertible -
A type-erased encodable value that forwards encoding responsibilities to an underlying value.
See moreDeclaration
Swift
public struct AnyEncodable : Encodableextension AnyEncodable: CustomStringConvertibleextension AnyEncodable: CustomDebugStringConvertibleextension AnyEncodable: ExpressibleByNilLiteralextension AnyEncodable: ExpressibleByBooleanLiteralextension AnyEncodable: ExpressibleByIntegerLiteralextension AnyEncodable: ExpressibleByFloatLiteralextension AnyEncodable: ExpressibleByArrayLiteralextension AnyEncodable: ExpressibleByDictionaryLiteral
View on GitHub
Data Reference