Json
public struct Json
-
Encode an object implementing
Encodable
to JSONThrows
An error if any value throws an error during encoding.Declaration
Swift
public static func encode<T>(_ value: T) throws -> RSTaggedData where T : Encodable
Parameters
value
the value to encode
Return Value
An
RSTaggedData
containing the encoded object -
Decode an object implementing
Decodable
from anRSTaggedData
Throws
DecodingError.dataCorrupted
if values requested from the payload are corrupted, or if the given data is not valid JSON.Throws
An error if any value throws an error during decoding.Declaration
Swift
public static func decode<T>(_ value: RSTaggedData) throws -> T where T : Decodable
Parameters
value
the data to decode
Return Value
the decoded object