I'm going to parse this JSON:

```
{
    "status": 1,
    "member": {
        "id": "3",
        "member_no": "1111",
        "username": "uname",
        "name": "name",
        "email": "user@name.com",
        "phone": "123 123",
        "point": "100",
        "expiry": "2019-09-22",
        "grade": {
            "id": "2",
            "name": "Member"
        }
    }
}

```

I created this struct:

```
struct User: Codable {
    var status: Int?
    var member: Member?
    var msg: String?

    struct Member: Codable {
        var id: Int?
        var member_no: String?
        var username: String?
        var name: String?
        var email: String?
        var phone: String?
        var point: String?
        var expiry: String?
        var grade: Grade?

        struct Grade: Codable {
            var id: Int?
            var name: String?
        }
    }
}

```

And use this to decode:

```
let decoder = JSONDecoder()
let user = try decoder.decode(User.self, from: data)

```

But I got this error:

> 
> The data couldn’t be read because it isn’t in the correct format.
> 
> 
> 

If the struct only one level, it is no problem:

```
struct User: Codable {
    var status: Int?
    var msg: String?
}

```

How to write a struct to match this JSON?