Skip to content

Commit 113de73

Browse files
committed
doc: Update README.md
1 parent 4066966 commit 113de73

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ struct CustomAdapter: JSONAdapter {
9898
decoder.valueNotFoundDecodingStrategy = .custom(CustomAdapter())
9999
```
100100

101+
可以通过 `JSONStringDecodingStrategy` 将 JSON 格式的字符串自动转成 `Codable` 对象或数组
102+
103+
```swift
104+
// 包含这些 key 的 JSON 字符串转成对象
105+
decoder.jsonStringDecodingStrategy = .containsKeys([])
106+
107+
// 所有 JSON 字符串都转成对象
108+
decoder.jsonStringDecodingStrategy = .all
109+
```
110+
101111
### For Moya
102112

103113
使用 `Moya.Response` 自带的 [map](https://github.com/Moya/Moya/blob/master/Sources/Moya/Response.swift) 方法解析,传入 `CleanJSONDecoder`

0 commit comments

Comments
 (0)