Fragment
public class Fragment: FragmentProtocol, ArrayFragment, DictionaryFragment
Fragment provides readonly access to data value. Fragment also provides subscript access by either key or index to the nested values which are wrapped by Fragment objects.
-
Gets the fragment value. The value types are Blob, Array, Dictionary, Number, or String based on the underlying data type; or nil if the value is nil.
Declaration
Swift
public var value: Any?
-
Gets the value as a string. Returns nil if the value is nil, or the value is not a string.
Declaration
Swift
public var string: String?
-
Gets the value as an int. Floating point values will be rounded. The value
true
is returned as 1,false
as 0. Returns 0 if the value is nil or is not a numeric value.Declaration
Swift
public var int: Int
-
Gets the value as an int64. Floating point values will be rounded. The value
true
is returned as 1,false
as 0. Returns 0 if the value is nil or is not a numeric value.Declaration
Swift
public var int64: Int64
-
Gets the value as a float. Integers will be converted to float. The value
true
is returned as 1.0,false
as 0.0. Returns 0.0 if the value is nil or is not a numeric value.Declaration
Swift
public var float: Float
-
Gets the value as a double. Integers will be converted to double. The value
true
is returned as 1.0,false
as 0.0. Returns 0.0 if the value is nil or is not a numeric value.Declaration
Swift
public var double: Double
-
Gets the value as a Number. Integers will be converted to double. The value
true
is returned as 1.0,false
as 0.0. Returns nil if the value is nil, or the value is not a Number.Declaration
Swift
public var number: NSNumber?
-
Gets the value as a boolean. Returns true if the value is not nil nor NSNull, and is either
true
or a nonzero number.Declaration
Swift
public var boolean: Bool
-
Gets the value as an Date. JSON does not directly support dates, so the actual property value must be a string, which is then parsed according to the ISO-8601 date format (the default used in JSON.) Returns nil if the value is nil, is not a string, or is not parseable as a date. NOTE: This is not a generic date parser! It only recognizes the ISO-8601 format, with or without milliseconds.
Declaration
Swift
public var date: Date?
-
Get the value as a Blob. Returns nil if the value is nil, or the value is not a Blob.
Declaration
Swift
public var blob: Blob?
-
Get the value as a ArrayObject, a mapping object of an array value. Returns nil if the value is nil, or the value is not an array.
Declaration
Swift
public var array: ArrayObject?
-
Get a property’s value as a DictionaryObject, a mapping object of a dictionary value. Returns nil if the value is nil, or the value is not a dictionary.
Declaration
Swift
public var dictionary: DictionaryObject?
-
Checks whether the value held by the fragment object exists or is nil value or not.
Declaration
Swift
public var exists: Bool
-
Subscript access to a Fragment object by index.
Declaration
Swift
public subscript(index: Int) -> Fragment
Parameters
index
The index
-
Subscript access to a Fragment object by key.
Declaration
Swift
public subscript(key: String) -> Fragment
Parameters
key
The key.