JSONValue
public enum JSONValue : Hashable, Sendable
extension JSONValue: RawRepresentable
extension JSONValue: ExpressibleByStringLiteral
extension JSONValue: ExpressibleByIntegerLiteral
extension JSONValue: ExpressibleByFloatLiteral
extension JSONValue: ExpressibleByBooleanLiteral
extension JSONValue: ExpressibleByArrayLiteral
extension JSONValue: ExpressibleByDictionaryLiteral
extension JSONValue: Codable
A JSON value represents an object, array, or fragment.
This type does not represent the null
value in JSON. Use Optional<JSONValue>
wherever null
is accepted.
-
A string.
Declaration
Swift
case string(_: String)
-
A floating-point number.
JSON does not distinguish numeric types of different precisions. If you need integer precision, cast the value to an
Int
.Declaration
Swift
case number(_: Double)
-
A Boolean value.
Declaration
Swift
case boolean(_: Bool)
-
A heterogeneous array of JSON values and
null
values.Declaration
Swift
case array(_: JSONArray)
-
An object containing JSON values and
null
values keyed by strings.Declaration
Swift
case object(_: JSONObject)
-
Initializes a JSON value representing the given string.
Declaration
Swift
public init(_ string: String)
-
Initializes a JSON value representing the given integer.
Declaration
Swift
public init<Source>(_ number: Source) where Source : BinaryInteger
Parameters
number
An integer. JSON does not distinguish numeric types of different precisions, so the integer is stored as a floating-point number.
-
Initializes a JSON value representing the given floating-point number.
Declaration
Swift
public init<Source>(_ number: Source) where Source : BinaryFloatingPoint
-
Initializes a JSON value representing the given Boolean value.
Declaration
Swift
public init(_ bool: Bool)
-
Initializes a JSON value representing the given JSON array.
Declaration
Swift
public init(_ values: JSONArray)
-
Initializes a JSON value representing the given JSON object.
Declaration
Swift
public init(_ properties: JSONObject)
-
Declaration
Swift
public typealias RawValue = Any
-
Declaration
Swift
public init?(rawValue: Any)
-
This branch must happen after the
NSNumber
branch to avoid convertingNSNumber
instances with values 0 and 1 but of objCType != ‘c’ toBool
sinceas? Bool
can succeed when the NSNumber’s value is 0 or 1 even when its objCType is not ‘c’.Declaration
Swift
public var rawValue: Any { get }
-
Declaration
Swift
public init(stringLiteral value: StringLiteralType)
-
Declaration
Swift
public init(integerLiteral value: IntegerLiteralType)
-
Declaration
Swift
public init(floatLiteral value: FloatLiteralType)
-
Declaration
Swift
public init(booleanLiteral value: BooleanLiteralType)
-
Declaration
Swift
public typealias ArrayLiteralElement = JSONValue?
-
Declaration
Swift
public init(arrayLiteral elements: ArrayLiteralElement...)
-
Declaration
Swift
public typealias Key = String
-
Declaration
Swift
public typealias Value = JSONValue?
-
-
Declaration
Swift
public init(from decoder: Decoder) throws
-
Declaration
Swift
public func encode(to encoder: Encoder) throws