Is there anyway to ensure that when parsing a JSON to a dictionary that the dictionary will contain data in the same order as received in the JSON (an ordered dictionary)?
I know that it is not possible in "native" parsing with Swift, so I'm wondering if there's a SwiftyJSON way.
Unfortunately, dictionary is an un-order data struct in Swift and Objective-C. You might need to use an array with some kind of sort algorithm. eg. array.sort() { $0.age < $1.age }. Closing for now. Feel free to open it if need. :)
thanks god I've found this question. Was very surprised by this native behaviour, spent a hours to figure out.
Most helpful comment
Unfortunately, dictionary is an un-order data struct in Swift and Objective-C. You might need to use an array with some kind of sort algorithm. eg.
array.sort() { $0.age < $1.age }. Closing for now. Feel free to open it if need. :)