I am working on a program that would generate swift classes/ structures for JSON file contents.

The link to the application is Json2Model in case you want to contribute directly.

I do not know a lot of Swift but this is what I came up with. These classes most likely will not hold any logic they are just data.


        "firstName": "John",
        "lastName": "Doe"
    "addresses": [
            "street": "Faraway Creek",
            "number": 1234,
            "city": "Never-land"
    "balance": 23234.23,
    "active": true

I want the following generated code to be reviewed.


struct Input {
    var addresses: [Address]
    let balance: Double
    let active: Bool
    let customer: Customer

    init(addresses: [Address], balance: Double, active: Bool, customer: Customer) {
        self.addresses = addresses;
        self.balance = balance;
        self.active = active;
        self.customer = customer;

    static func load() {
        //TODO: Needs to be implemented.



struct Address {
    let number: Int
    let city: String
    let street: String

    init(number: Int, city: String, street: String) {
        self.number = number;
        self.city = city;
        self.street = street;



struct Customer {
    let firstName: String
    let lastName: String

    init(firstName: String, lastName: String) {
        self.firstName = firstName;
        self.lastName = lastName;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy