@@ -35,50 +35,44 @@ func decodeFromJSON<T: Decodable>(json: UnsafeBufferPointer<UInt8>) throws -> T
35
35
}
36
36
}
37
37
38
- /*
39
- JSONMap is inspired by swift-foundation's JSONMap.
40
-
41
- For JSON payload such as:
42
-
43
- ```
44
- {"foo": [-1.3, true], "barz": 42}
45
- ```
46
-
47
- will be scanned by 'JSONScanner' into a map like:
48
-
49
- ```
50
- <OM> == Object Marker
51
- <AM> == Array Marker
52
- <SS> == Simple String (a variant of String that can has no escapes and can be passed directly to a UTF-8 parser)
53
- <NM> == Number Marker
54
- <TL> == NULL Marker
55
- map: [
56
- 0: <OM>, -- object marker
57
- 1: 17, | `- number of *map* elements this object occupies
58
- 2: <SS>, | --- key 1: 'foo'
59
- 3: <int_ptr>, | | |- pointer in the payload
60
- 4: 3, | | `- length
61
- 5: <AM>, | --- value 1: array
62
- 6: 6, | | `- number of *map* elements this array occupies
63
- 7: <NM>, | | -- arr elm 1: '-1.3'
64
- 8: <int_ptr>, | | |
65
- 9: 4, | | |
66
- 10: <TL>, | | -- arr elm 2: 'true'
67
- 11: <SS>, | --- key 2: 'barz'
68
- 12: <int_ptr>, | |
69
- 13: 4, | |
70
- 14: <NM> | --- value 2: '42'
71
- 15: <int_ptr>, | |
72
- 16: 2, | |
73
- ]
74
- ```
75
- To decode '<root>.barz' value:
76
- 1. Index 0 indicates it's a object.
77
- 2. Parse a key string at index 2, which is "foo", not a match for "barz"
78
- 3. Skip the key and the value by advancing the index by 'mapSize' of them, 3 and 6.
79
- 4. Parse a key string at index 11, matching "barz"
80
- 5. Parse a value number at the pointer of index 15, length at index 16
81
- */
38
+ // JSONMap is inspired by swift-foundation's JSONMap.
39
+ // For JSON payload such as:
40
+ // ```
41
+ // {"foo": [-1.3, true], "barz": 42}
42
+ // ```
43
+ // will be scanned by 'JSONScanner' into a map like:
44
+ // ```
45
+ // <OM> == Object Marker
46
+ // <AM> == Array Marker
47
+ // <SS> == Simple String (a variant of String that can has no escapes and can be passed directly to a UTF-8 parser)
48
+ // <NM> == Number Marker
49
+ // <TL> == NULL Marker
50
+ // map: [
51
+ // 0: <OM>, -- object marker
52
+ // 1: 17, | `- number of *map* elements this object occupies
53
+ // 2: <SS>, | --- key 1: 'foo'
54
+ // 3: <int_ptr>, | | |- pointer in the payload
55
+ // 4: 3, | | `- length
56
+ // 5: <AM>, | --- value 1: array
57
+ // 6: 6, | | `- number of *map* elements this array occupies
58
+ // 7: <NM>, | | -- arr elm 1: '-1.3'
59
+ // 8: <int_ptr>, | | |
60
+ // 9: 4, | | |
61
+ // 10: <TL>, | | -- arr elm 2: 'true'
62
+ // 11: <SS>, | --- key 2: 'barz'
63
+ // 12: <int_ptr>, | |
64
+ // 13: 4, | |
65
+ // 14: <NM> | --- value 2: '42'
66
+ // 15: <int_ptr>, | |
67
+ // 16: 2, | |
68
+ // ]
69
+ // ```
70
+ // To decode '<root>.barz' value:
71
+ // 1. Index 0 indicates it's a object.
72
+ // 2. Parse a key string at index 2, which is "foo", not a match for "barz"
73
+ // 3. Skip the key and the value by advancing the index by 'mapSize' of them, 3 and 6.
74
+ // 4. Parse a key string at index 11, matching "barz"
75
+ // 5. Parse a value number at the pointer of index 15, length at index 16
82
76
83
77
private struct JSONMap {
84
78
enum Descriptor : Int {
0 commit comments