CodableCode

1.0.5

Swift Package that allows you to convert JSON Strings into Swift structs.
juliofruta/CodableCode

What's New

Line breaks

2023-10-01T05:16:39Z

line break bug fixes

String + CodableCode

Instance Property

CodableCode

Codable code is a Swift Package that allows you to convert JSON Strings into Swift structs.


The following code:

print(try! """
{
  "greeting": "Welcome to quicktype!",
  "instructions": [
    "Type or paste JSON here",
    "Or choose a sample above",
    "quicktype will generate code in your",
    "chosen language to parse the sample data"
  ]
}
""".codableCode())

Outputs:

struct <#SomeType#>: Codable {
    let greeting: String
    let instructions: [String]
    enum CodingKeys: String, CodingKey {
        case greeting = "greeting"
        case instructions = "instructions"
    }
}

Declaration

Throwing an error and setting a type name

codableCode(name: String = "<#SomeType#>") throws -> String

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

Last updated: Wed Mar 13 2024 21:59:41 GMT-0900 (Hawaii-Aleutian Daylight Time)