Skip to content

Commit a4ba9e5

Browse files
committed
Add back the old init signatures.
Fixes apple#1022.
1 parent c0d2835 commit a4ba9e5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Sources/SwiftProtobuf/Message+JSONAdditions.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ extension Message {
5959
return visitor.dataResult
6060
}
6161

62+
/// Creates a new message by decoding the given string containing a
63+
/// serialized message in JSON format.
64+
///
65+
/// - Parameter jsonString: The JSON-formatted string to decode.
66+
/// - Parameter options: The JSONDecodingOptions to use.
67+
/// - Throws: `JSONDecodingError` if decoding fails.
68+
public init(
69+
jsonString: String,
70+
options: JSONDecodingOptions = JSONDecodingOptions()
71+
) throws {
72+
try self.init(jsonString: jsonString, extensions: nil, options: options)
73+
}
74+
6275
/// Creates a new message by decoding the given string containing a
6376
/// serialized message in JSON format.
6477
///
@@ -81,6 +94,21 @@ extension Message {
8194
}
8295
}
8396

97+
/// Creates a new message by decoding the given `Data` containing a
98+
/// serialized message in JSON format, interpreting the data as UTF-8 encoded
99+
/// text.
100+
///
101+
/// - Parameter jsonUTF8Data: The JSON-formatted data to decode, represented
102+
/// as UTF-8 encoded text.
103+
/// - Parameter options: The JSONDecodingOptions to use.
104+
/// - Throws: `JSONDecodingError` if decoding fails.
105+
public init(
106+
jsonUTF8Data: Data,
107+
options: JSONDecodingOptions = JSONDecodingOptions()
108+
) throws {
109+
try self.init(jsonUTF8Data: jsonUTF8Data, extensions: nil, options: options)
110+
}
111+
84112
/// Creates a new message by decoding the given `Data` containing a
85113
/// serialized message in JSON format, interpreting the data as UTF-8 encoded
86114
/// text.

0 commit comments

Comments
 (0)