Skip to content

Commit

Permalink
Use sorted keys when encoding using the JSON strategy (#20)
Browse files Browse the repository at this point in the history
* Use sorted keys when encoding using the JSON strategy

* Bump macOS min deployment target to 10.13 and tvOS to 11
  • Loading branch information
liamnichols committed Jan 26, 2024
1 parent bc410dc commit 2fcd945
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Expand Up @@ -6,10 +6,10 @@ import PackageDescription
let package = Package(
name: "swift-user-defaults",
platforms: [
.macOS(.v10_12),
.macOS(.v10_13),
.iOS(.v11),
.watchOS(.v7),
.tvOS(.v10)
.tvOS(.v11)
],
products: [
.library(name: "SwiftUserDefaults", targets: ["SwiftUserDefaults"]),
Expand Down
4 changes: 3 additions & 1 deletion Sources/SwiftUserDefaults/UserDefaults+CodingStrategy.swift
Expand Up @@ -42,7 +42,9 @@ public extension UserDefaults.CodingStrategy {
func encode<T: Encodable>(_ value: T) throws -> Data {
switch self {
case .json:
return try JSONEncoder().encode(value)
let encoder = JSONEncoder()
encoder.outputFormatting = .sortedKeys
return try encoder.encode(value)
case .plist:
return try PropertyListEncoder().encode(value)
}
Expand Down
4 changes: 2 additions & 2 deletions swift-user-defaults.podspec
Expand Up @@ -11,8 +11,8 @@ Pod::Spec.new do |s|
s.swift_version = "5.3"

s.ios.deployment_target = '11.0'
s.osx.deployment_target = '10.12'
s.tvos.deployment_target = '10.0'
s.osx.deployment_target = '10.13'
s.tvos.deployment_target = '11.0'
s.watchos.deployment_target = '7'

# Run Unit Tests
Expand Down

0 comments on commit 2fcd945

Please sign in to comment.