File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,14 @@ extension JSON.Array {
66 public init ( parsing json: JSON ) throws {
77 self . init ( try JSON . NodeRule< Int> . Array. parse ( json. utf8) )
88 }
9+ /// Attempts to parse a JSON array from a raw span
10+ public init ( parsing span: RawSpan ) throws {
11+ self . init (
12+ try span. withUnsafeBytes { buffer in
13+ try JSON . NodeRule< Int> . Array. parse ( buffer)
14+ }
15+ )
16+ }
917 /// Attempts to parse a JSON array from a string.
1018 public init ( parsing string: String ) throws {
1119 self . init ( try JSON . NodeRule< String . Index> . Array. parse ( string. utf8) )
Original file line number Diff line number Diff line change @@ -8,6 +8,13 @@ extension JSON.Node {
88 self = try JSON . RootRule< Int> . parse( json. utf8)
99 }
1010 /// Attempts to parse a complete JSON message (either an ``Array`` or an
11+ /// ``Object``) from a raw span.
12+ public init ( parsing span: RawSpan ) throws {
13+ self = try span. withUnsafeBytes { buffer in
14+ try JSON . RootRule< Int> . parse( buffer)
15+ }
16+ }
17+ /// Attempts to parse a complete JSON message (either an ``Array`` or an
1118 /// ``Object``) from a string.
1219 public init ( parsing string: String ) throws {
1320 self = try JSON . RootRule< String . Index> . parse( string. utf8)
Original file line number Diff line number Diff line change @@ -9,6 +9,14 @@ extension JSON.Object {
99 public init ( parsing json: JSON ) throws {
1010 self . init ( try JSON . NodeRule< Int> . Object. parse ( json. utf8) )
1111 }
12+ /// Attempts to parse a JSON object from a raw span.
13+ public init ( parsing span: RawSpan ) throws {
14+ self . init (
15+ try span. withUnsafeBytes { buffer in
16+ try JSON . NodeRule< Int> . Object. parse ( buffer)
17+ }
18+ )
19+ }
1220 /// Attempts to parse a JSON object from a string.
1321 ///
1422 /// > Note:
You can’t perform that action at this time.
0 commit comments