Update README.md

This commit is contained in:
Zach Eriksen 2021-06-22 20:13:00 -05:00 committed by GitHub
parent 51f78f6102
commit 62a3d1f34a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 37 additions and 0 deletions

View File

@ -30,3 +30,40 @@ struct ContentView: View {
}
}
```
### JSON Example
```swift
struct ContentView: View {
let json = """
{
"userId": 1,
"id": 2,
"title": "quis ut nam facilis et officia qui",
"completed": false
}
"""
.data(using: .utf8)
var body: some View {
ObjectView(data: json) { object in
VStack {
object.userId.value(as: Int.self).map { userId in
Text("\(userId)")
}
object.id.value(as: Int.self).map { id in
Text("\(id)")
}
object.title.value(as: String.self).map { title in
Text(title)
}
object.completed.value(as: Bool.self).map { completed in
Text(completed.description)
}
}
}
}
}
```