JSONSerializableObject

public class JSONSerializableObject
extension JSONSerializableObject: SerializableObject
extension JSONSerializableObject: Equatable
extension JSONSerializableObject: CustomStringConvertible

The default implementation of SerializableObject protocol that serializes the object’s content into JSON.

  • Support change types for the object’s properties.

    • Replace: Replace the property’s value/s.
    • Delete: Delete the property.

    Declaration

    Swift

    public enum ChangeType
  • Declaration

    Swift

    private(set) public var version: Int { get }
  • Declaration

    Swift

    fileprivate(set) public var properties: [String : Any] { get }
  • List of changes that occurred to this object’s properties since it’s construction.

    Declaration

    Swift

    private(set) public var changes: [String : (ChangeType, Any)] { get }
  • Intializes a new JSONSerializableObject instance.

    Declaration

    Swift

    public init()

    Return Value

    A new initialized SerializableObjectImpl instance.

  • Intializes a new JSONSerializableObject instance but as a copy from another instance.

    Declaration

    Swift

    public init(other: JSONSerializableObject)

    Parameters

    other

    JSONSerializableObject to copy.

    Return Value

    A new initialized JSONSerializableObject instance.

  • Intializes a new JSONSerializableObject instance from the serialized object data.

    Declaration

    Swift

    public convenience init?(data: Data)

    Parameters

    data

    Serialized object data.

    Return Value

    A new initialized JSONSerializableObject instance.

  • Intializes a new SerializableObjectImpl instance from a dictionary encapsulating the object’s properties.

    • Return: A new initialized SerializableObjectImpl instance.

    Declaration

    Swift

    public convenience init?(properties: [String : Any])

    Parameters

    properties

    Dictionary of object’s properties.

  • Sets a String property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: String?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets an Integer property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: Int?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets a Double property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: Double?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets a Boolean property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: Bool)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets a Date property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: Date?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets a SerializableObject property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: JSONSerializableObject?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets a String array property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: [String]?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets an Integer array property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: [Int]?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets a Double array property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: [Double]?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets a Boolean array property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: [Bool]?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets a Date array property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: [Date]?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Sets a SerializableObject array property.

    Declaration

    Swift

    public func setProperty(_ name: String, value: [JSONSerializableObject]?)

    Parameters

    name

    Property name.

    value

    Property value.

  • Remmoves a property.

    Declaration

    Swift

    public func removeProperty(_ name: String)

    Parameters

    name

    Property name.

  • Returns the value of the specified String property.

    Declaration

    Swift

    public func getPropertyAsString(_ name: String) -> String?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exist.

  • Returns the value of the specified Integer property.

    Declaration

    Swift

    public func getPropertyAsInt(_ name: String) -> Int?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exist.

  • Returns the value of the specified Double property.

    Declaration

    Swift

    public func getPropertyAsDouble(_ name: String) -> Double?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exist.

  • Returns the value of the specified Boolean property.

    Declaration

    Swift

    public func getPropertyAsBool(_ name: String) -> Bool

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exist.

  • Returns the value of the specified Date property.

    Declaration

    Swift

    public func getPropertyAsDate(_ name: String) -> Date?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exists.

  • Returns the value of the specified SerializableObject property.

    Declaration

    Swift

    public func getPropertyAsSerializableObject(_ name: String) -> JSONSerializableObject?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exists.

  • Returns the value of the specified string array property.

    Declaration

    Swift

    public func getPropertyAsStringArray(_ name: String) -> [String]?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exists.

  • Returns the value of the specified boolean array property.

    Declaration

    Swift

    public func getPropertyAsBoolArray(_ name: String) -> [Bool]?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exists.

  • Returns the value of the specified integer array property.

    Declaration

    Swift

    public func getPropertyAsIntArray(_ name: String) -> [Int]?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exists.

  • Returns the value of the specified double array property.

    Declaration

    Swift

    public func getPropertyAsDoubleArray(_ name: String) -> [Double]?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exists.

  • Returns the value of the specified date array property.

    Declaration

    Swift

    public func getPropertyAsDateArray(_ name: String) -> [Date]?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exists.

  • Returns the value of the specified serialiable object array property.

    Declaration

    Swift

    public func getPropertyAsSerializableObjectArray(_ name: String) -> [JSONSerializableObject]?

    Parameters

    name

    Property name.

    Return Value

    Specified property’s value or nil if the property does not exists.

  • Clears the change list associated with this object.

    Declaration

    Swift

    public func clearChanges()
  • Declaration

    Swift

    public func toData() throws -> Data
  • Declaration

    Swift

    public func loadFromData(_ data: Data) throws
  • Declaration

    Swift

    public static func == (lhs: JSONSerializableObject, rhs: JSONSerializableObject) -> Bool
  • Declaration

    Swift

    public var description: String { get }