[swift-evolution] [Proposal] Foundation Swift Encoders

Ben Rimmington me at benrimmington.com
Thu Mar 16 16:57:13 CDT 2017

Sorry, I actually meant that keys would be ordered **alphabetically** (as they are with PropertyListSerialization).

I'm storing output from JSONSerialization in a git repository, and when I add/remove a single key-value the entire file changes, due to keys being reordered (seemingly at random).

-- Ben

> Itai Ferber wrote:
> By stable ordering, you mean dictionaries with keys being output in the order that they were encoded?
> Potentially, but this would require additional work as neither Swift dictionaries nor NSMutableDictionary support this (reasonable seeing as dictionaries are by definition not sorted), and the current implementation uses JSONSerialization as the concrete serializer. Certainly not impossible, though.
>> On 16 Mar 2017, at 8:49, Ben Rimmington wrote:
>> <https://github.com/apple/swift-evolution/pull/640>
>> Could the `JSONEncoder.OutputFormatting.prettyPrinted` case include the **stable ordering** of keys?
>> -- Ben

More information about the swift-evolution mailing list