Skip to content

Commit c871e3a

Browse files
authored
nilEncodingStrategy
1 parent bde5fc8 commit c871e3a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The default strategy preserves `Optional.none`:
6666

6767
```swift
6868
let encoder = KeyValueEncoder()
69-
encoder.strategy = .default
69+
encoder.nilEncodingStrategy = .default
7070

7171
// [1, 2, nil, 3]
7272
let any = try encoder.encode([1, 2, Int?.none, 3])
@@ -75,7 +75,7 @@ let any = try encoder.encode([1, 2, Int?.none, 3])
7575
Compatibility with [`PropertyListEncoder`](https://developer.apple.com/documentation/foundation/propertylistencoder) is preserved using a placeholder string:
7676

7777
```swift
78-
encoder.strategy = .stringNull
78+
encoder.nilEncodingStrategy = .stringNull
7979

8080
// [1, 2, "$null", 3]
8181
let any = try encoder.encode([1, 2, Int?.none, 3])
@@ -84,7 +84,7 @@ let any = try encoder.encode([1, 2, Int?.none, 3])
8484
Compatibility with [`JSONSerialization`](https://developer.apple.com/documentation/foundation/jsonserialization) is preserved using [`NSNull`](https://developer.apple.com/documentation/foundation/nsnull):
8585

8686
```swift
87-
encoder.strategy = .nsNull
87+
encoder.nilEncodingStrategy = .nsNull
8888

8989
// [1, 2, NSNull(), 3]
9090
let any = try encoder.encode([1, 2, Int?.none, 3])
@@ -93,7 +93,7 @@ let any = try encoder.encode([1, 2, Int?.none, 3])
9393
Nil values can also be completely removed:
9494

9595
```swift
96-
encoder.strategy = .removed
96+
encoder.nilEncodingStrategy = .removed
9797

9898
// [1, 2, 3]
9999
let any = try encoder.encode([1, 2, Int?.none, 3])

0 commit comments

Comments
 (0)