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
JSONSerializableObjectinstance.Declaration
Swift
public init()Return Value
A new initialized
SerializableObjectImplinstance. -
Intializes a new
JSONSerializableObjectinstance but as a copy from another instance.Declaration
Swift
public init(other: JSONSerializableObject)Parameters
otherJSONSerializableObjectto copy.Return Value
A new initialized
JSONSerializableObjectinstance. -
Intializes a new
JSONSerializableObjectinstance from the serialized object data.Declaration
Swift
public convenience init?(data: Data)Parameters
dataSerialized object data.
Return Value
A new initialized
JSONSerializableObjectinstance. -
Intializes a new
SerializableObjectImplinstance from a dictionary encapsulating the object’s properties.Return: A new initialized
SerializableObjectImplinstance.
Declaration
Swift
public convenience init?(properties: [String : Any])Parameters
propertiesDictionary of object’s properties.
-
Sets a String property.
Declaration
Swift
public func setProperty(_ name: String, value: String?)Parameters
nameProperty name.
valueProperty value.
-
Sets an Integer property.
Declaration
Swift
public func setProperty(_ name: String, value: Int?)Parameters
nameProperty name.
valueProperty value.
-
Sets a Double property.
Declaration
Swift
public func setProperty(_ name: String, value: Double?)Parameters
nameProperty name.
valueProperty value.
-
Sets a Boolean property.
Declaration
Swift
public func setProperty(_ name: String, value: Bool)Parameters
nameProperty name.
valueProperty value.
-
Sets a Date property.
Declaration
Swift
public func setProperty(_ name: String, value: Date?)Parameters
nameProperty name.
valueProperty value.
-
Sets a
SerializableObjectproperty.Declaration
Swift
public func setProperty(_ name: String, value: JSONSerializableObject?)Parameters
nameProperty name.
valueProperty value.
-
Sets a String array property.
Declaration
Swift
public func setProperty(_ name: String, value: [String]?)Parameters
nameProperty name.
valueProperty value.
-
Sets an Integer array property.
Declaration
Swift
public func setProperty(_ name: String, value: [Int]?)Parameters
nameProperty name.
valueProperty value.
-
Sets a Double array property.
Declaration
Swift
public func setProperty(_ name: String, value: [Double]?)Parameters
nameProperty name.
valueProperty value.
-
Sets a Boolean array property.
Declaration
Swift
public func setProperty(_ name: String, value: [Bool]?)Parameters
nameProperty name.
valueProperty value.
-
Sets a Date array property.
Declaration
Swift
public func setProperty(_ name: String, value: [Date]?)Parameters
nameProperty name.
valueProperty value.
-
Sets a
SerializableObjectarray property.Declaration
Swift
public func setProperty(_ name: String, value: [JSONSerializableObject]?)Parameters
nameProperty name.
valueProperty value.
-
Remmoves a property.
Declaration
Swift
public func removeProperty(_ name: String)Parameters
nameProperty name.
-
Returns the value of the specified String property.
Declaration
Swift
public func getPropertyAsString(_ name: String) -> String?Parameters
nameProperty 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
nameProperty 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
nameProperty 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) -> BoolParameters
nameProperty 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
nameProperty name.
Return Value
Specified property’s value or nil if the property does not exists.
-
Returns the value of the specified
SerializableObjectproperty.Declaration
Swift
public func getPropertyAsSerializableObject(_ name: String) -> JSONSerializableObject?Parameters
nameProperty 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
nameProperty 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
nameProperty 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
nameProperty 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
nameProperty 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
nameProperty 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
nameProperty 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 }
JSONSerializableObject Class Reference