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

Progress to user when parsing many records? #111

Open
davros1970 opened this issue May 31, 2017 · 2 comments
Open

Progress to user when parsing many records? #111

davros1970 opened this issue May 31, 2017 · 2 comments
Labels

Comments

@davros1970
Copy link

I could use a suggestion on how to best provide progress when parsing a JSON array of a zillion records. Been using the frameworks simple syntax to unmarshal the array with my object implementing Unmarshaling protocol. Works perfectly fine, but when I have many records, how can I provide a 'percent complete' back to the user?

`
// This one liner blasts thru the millions of elements in my JSON array to unmarshal,
// but doesn't let me know which index its on so I can give the user progress feedback.

let records: [MyRecord] = try? jsonObject.value(for: "BillonsOfRecords")
`

@jarsen
Copy link
Member

jarsen commented May 31, 2017

That's a good question. As designed, I don't believe there's a good way for any of the existing API to expose and index. I'm not sure of a good way to handle this short of writing your own version of one of the existing functions that takes a closure which can accept an index and is called on each pass of the mapping.

@bwhiteley
Copy link
Contributor

I wonder if you could do something with UnmarshalingWithContext.

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

No branches or pull requests

3 participants