ReadOnlyDictionaryObject

public class ReadOnlyDictionaryObject: ReadOnlyDictionaryProtocol

ReadOnlyDictionaryObject provides readonly access to dictionary data.

  • The number of entries in the dictionary.

    Declaration

    Swift

    public var count: Int
  • An array containing all keys, or an empty array if the dictionary has no entries.

    Declaration

    Swift

    public var keys: Array<String>
  • Get a property’s value as a ReadOnlyArrayObject, which is a mapping object of an array value. Returns nil if the property doesn’t exists, or its value is not an array.

    Declaration

    Swift

    public func array(forKey key: String) -> ReadOnlyArrayObject?

    Parameters

    key

    The key.

    Return Value

    The ReadOnlyArrayObject object or nil.

  • Get a property’s value as a Blob object. Returns nil if the property doesn’t exist, or its value is not a blob.

    Declaration

    Swift

    public func blob(forKey key: String) -> Blob?

    Parameters

    key

    The key.

    Return Value

    The Blob object or nil.

  • Gets a property’s value as a boolean value. Returns true if the value exists, and is either true or a nonzero number.

    Declaration

    Swift

    public func boolean(forKey key: String) -> Bool

    Parameters

    key

    The key.

    Return Value

    The Bool value.

  • Gets a property’s value as a Date value. 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 doesn’t exist, 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 func date(forKey key: String) -> Date?

    Parameters

    key

    The key.

    Return Value

    The Date value or nil

  • Get a property’s value as a ReadOnlyDictionaryObject, which is a mapping object of a dictionary value. Returns nil if the property doesn’t exists, or its value is not a dictionary.

    Declaration

    Swift

    public func dictionary(forKey key: String) -> ReadOnlyDictionaryObject?

    Parameters

    key

    The key.

    Return Value

    THe ReadOnlyDictionaryObject object or nil.

  • Gets a property’s value as a float value. Integers will be converted to float. The value true is returned as 1.0, false as 0.0. Returns 0.0 if the property doesn’t exist or does not have a numeric value.

    Declaration

    Swift

    public func float(forKey key: String) -> Float

    Parameters

    key

    The key.

    Return Value

    The Float value.

  • Gets a property’s value as a double value. Integers will be converted to double. The value true is returned as 1.0, false as 0.0. Returns 0.0 if the property doesn’t exist or does not have a numeric value.

    Declaration

    Swift

    public func double(forKey key: String) -> Double

    Parameters

    key

    The key.

    Return Value

    The Double value.

  • Gets a property’s value as an int value. Floating point values will be rounded. The value true is returned as 1, false as 0. Returns 0 if the property doesn’t exist or does not have a numeric value.

    Declaration

    Swift

    public func int(forKey key: String) -> Int

    Parameters

    key

    The key.

    Return Value

    The Int value.

  • Gets a property’s value as an int64 value. Floating point values will be rounded. The value true is returned as 1, false as 0. Returns 0 if the property doesn’t exist or does not have a numeric value.

    Declaration

    Swift

    public func int64(forKey key: String) -> Int64

    Parameters

    key

    The key.

    Return Value

    The Int64 value.

  • Gets a property’s value as a string. Returns nil if the property doesn’t exist, or its value is not a string.

    Declaration

    Swift

    public func string(forKey key: String) -> String?

    Parameters

    key

    The key.

    Return Value

    The String object or nil.

  • Gets a property’s value. The value types are Blob, ReadOnlyArrayObject, ReadOnlyDictionaryObject, Number, or String based on the underlying data type; or nil if the value is nil or the property doesn’t exist.

    Declaration

    Swift

    public func value(forKey key: String) -> Any?

    Parameters

    key

    The key.

    Return Value

    The value or nil.

  • Tests whether a property exists or not. This can be less expensive than -objectForKey:, because it does not have to allocate an NSObject for the property value.

    Declaration

    Swift

    public func contains(_ key: String) -> Bool

    Parameters

    key

    The key.

    Return Value

    True of the property exists, otherwise false.

  • Gets content of the current object as a Dictionary. The values contained in the returned Dictionary object are all JSON based values.

    Declaration

    Swift

    public func toDictionary() -> Dictionary<String, Any>

    Return Value

    The Dictionary object representing the content of the current object in the JSON format.

  • Gets an iterator over the keys of the dictionary entries

    Declaration

    Swift

    public func makeIterator() -> IndexingIterator<[String]>

    Return Value

    The key iterator.

  • Subscript access to a ReadOnlyFragment object by key.

    Declaration

    Swift

    public subscript(key: String) -> ReadOnlyFragment

    Parameters

    key

    The key.