Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of Object Not working #66

Open
chathuralakmal opened this issue Jan 24, 2018 · 0 comments
Open

Array of Object Not working #66

chathuralakmal opened this issue Jan 24, 2018 · 0 comments

Comments

@chathuralakmal
Copy link

I have JSON array like this.

{
    "id": "7397632",
    "studentid": "554",
    "daily_attendance": [
        {
            "period_id": "29",
            "attendance_type_id": "1"
        },
        {
            "period_id": "30",
            "attendance_type_id": "1"
        },
        {
            "period_id": "31",
            "attendance_type_id": "1"
        },
        {
            "period_id": "32",
            "attendance_type_id": "1"
        }
    ]
},
{
    "id": "5397643",
    "studentid": "626",
    "daily_attendance": [
      
      {
            "period_id": "30",
            "attendance_type_id": "1"
        },
        {
            "period_id": "31",
            "attendance_type_id": "1"
        },
        {
            "period_id": "32",
            "attendance_type_id": "1"
        }
    ]
}

This is my class

import JSONJoy
struct StudentTimeTable : JSONJoy {

let id : String?
let studentid : String?
let daily_attendance : [Daily_attendance]?


init(_ decoder: JSONLoader) throws {
    id = try decoder["id"].get()
    studentid = try decoder["studentid"].get()
    //daily_attendance = try [Daily_attendance(decoder["daily_attendance"])]
    daily_attendance = try decoder["daily_attendance"].get()
}

Problem is it does not create the 'daily_attendance' array Object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant