Making JSON have both sorted keys and pretty printed Dec 26, 2020 let encoder = JSONEncoder() encoder.outputFormatting = JSONEncoder.OutputFormatting([.prettyPrinted, .sortedKeys])