Skip to content

Commit 2a28449

Browse files
committed
Improve JSON output readability with sortedKeys
1 parent b039ce2 commit 2a28449

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

APIService/Sources/Support/JSONConvertible.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension JSONConvertible {
1717
return nil
1818
}
1919

20-
let options: JSONSerialization.WritingOptions = prettyPrinted ? [.prettyPrinted] : []
20+
let options: JSONSerialization.WritingOptions = prettyPrinted ? [.prettyPrinted, .sortedKeys] : [.sortedKeys]
2121

2222
do {
2323
let jsonData = try JSONSerialization.data(withJSONObject: self, options: options)
@@ -45,7 +45,7 @@ extension Data: JSONConvertible {
4545
return self.toUTF8String(maxLength: maxLength)
4646
}
4747

48-
let options: JSONSerialization.WritingOptions = prettyPrinted ? [.prettyPrinted, .sortedKeys] : []
48+
let options: JSONSerialization.WritingOptions = prettyPrinted ? [.prettyPrinted, .sortedKeys] : [.sortedKeys]
4949

5050
do {
5151
let jsonData = try JSONSerialization.data(withJSONObject: jsonObject, options: options)

0 commit comments

Comments
 (0)