LDValue

public enum LDValue: Codable,
                     Equatable,
                     ExpressibleByNilLiteral,
                     ExpressibleByBooleanLiteral,
                     ExpressibleByIntegerLiteral,
                     ExpressibleByFloatLiteral,
                     ExpressibleByStringLiteral,
                     ExpressibleByArrayLiteral,
                     ExpressibleByDictionaryLiteral
extension LDValue: LDValueConvertible

An immutable instance of any data type that is allowed in JSON.

An LDValue can be a null (that is, an instance that represents a JSON null value), a boolean, a number (always encoded internally as double-precision floating-point), a string, an ordered list of LDValue values (a JSON array), or a map of strings to LDValue values (a JSON object).

This can be used to represent complex data in a context attribute, or to get a feature flag value that uses a complex type or does not always use the same type.

  • Declaration

    Swift

    public typealias StringLiteralType = String
  • Declaration

    Swift

    public typealias ArrayLiteralElement = LDValue
  • Key

    Declaration

    Swift

    public typealias Key = String
  • Declaration

    Swift

    public typealias Value = LDValue
  • Declaration

    Swift

    public typealias IntegerLiteralType = Double
  • Declaration

    Swift

    public typealias FloatLiteralType = Double
  • Represents a JSON null value.

    Declaration

    Swift

    case null
  • Represents a JSON boolean value.

    Declaration

    Swift

    case bool(Bool)
  • Represents a JSON number value.

    Declaration

    Swift

    case number(Double)
  • Represents a JSON string value.

    Declaration

    Swift

    case string(String)
  • Represents an array of JSON values.

    Declaration

    Swift

    case array([LDValue])
  • Represents a JSON object.

    Declaration

    Swift

    case object([String : LDValue])
  • Declaration

    Swift

    public init(nilLiteral: ())
  • Declaration

    Swift

    public init(booleanLiteral: Bool)
  • Create an LDValue representation from the provided Double value.

    This method DOES NOT truncate the provided Double. As JSON numeric values are always treated as double-precision, this method will store the given Double as it.

    Declaration

    Swift

    @available(*, deprecated, message: "Use LDValue.init(integerLiteral: Int﹚ or LDValue.init(floatLiteral: Double﹚")
    public init(integerLiteral: Double)
  • Create an LDValue representation from the provided Int.

    All JSON numeric types are represented as double-precision so the provided Int will be cast to a Double.

    Declaration

    Swift

    public init(integerLiteral: Int)
  • Create an LDValue representation from the provided Double.

    Declaration

    Swift

    public init(floatLiteral: Double)
  • Declaration

    Swift

    public init(stringLiteral: String)
  • Declaration

    Swift

    public init(arrayLiteral: LDValue...)
  • Declaration

    Swift

    public init(dictionaryLiteral: (String, LDValue)...)
  • Declaration

    Swift

    public init(from decoder: Decoder) throws
  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws
  • Declaration

    Swift

    public func toLDValue() -> LDValue