Open davros1970 opened 7 years ago
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.
I wonder if you could do something with UnmarshalingWithContext
.
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") `