Encodable
public extension Encodable
-
Encodes an
Encodableobject as a json string.Throws
If the object cannot be encoded to json.Declaration
Swift
func toJsonString(convertToSnakeCase: Bool = false, prettyPrinted: Bool = false) throws -> StringParameters
convertToSnakeCaseShould camelCase keys be converted to snake_case? (default = false)
prettyPrintedShould the output be prettyPrinted? (default = false)
Return Value
A json string.
-
Encodes an
Encodableobject as a json string.Throws
If the object cannot be encoded into a JSON object.Declaration
Swift
func toJsonData(convertToSnakeCase: Bool = false, prettyPrinted: Bool = false) throws -> DataParameters
convertToSnakeCaseShould camelCase keys be converted to snake_case? (default = false)
prettyPrintedShould the output be prettyPrinted? (default = false)
Return Value
A Data object.
-
Encodes an
Encodableobject as a dictionary of type[String: Any].Declaration
Swift
func toDictionary() -> [String : Any]?Return Value
A dictionary of type
[String: Any]. -
Encodes an
Encodableobject as a array of type[Any].Declaration
Swift
func toArray() -> [Any]?Return Value
A dictionary of type
[Any].
View on GitHub
Encodable Extension Reference