We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
JSON.Object
1 parent 8b441f3 commit e66dba5Copy full SHA for e66dba5
Sources/JSONDecoding/JSON.Object (ext).swift
@@ -1,3 +1,12 @@
1
+extension JSON.Object {
2
+ @inlinable public subscript(key: JSON.Key) -> JSON.OptionalDecoder<JSON.Key> {
3
+ JSON.OptionalDecoder(key: key, value: fields.first { $0.key == key }?.value)
4
+ }
5
+
6
+ @inlinable public subscript(key: JSON.Key) -> JSON.FieldDecoder<JSON.Key>? {
7
+ (fields.first { $0.key == key }?.value).map { JSON.FieldDecoder(key: key, value: $0) }
8
9
+}
10
extension JSON.Object: RandomAccessCollection {
11
@inlinable public var startIndex: Int {
12
self.fields.startIndex
0 commit comments