     return visitor.stringResult
 }
 
+fileprivate func serializeAnyJSON(wktValueJSON value: String, typeURL: String) throws -> String {
+    var jsonEncoder = JSONEncoder()
+    jsonEncoder.startObject()
+    jsonEncoder.startField(name: "@type")
+    jsonEncoder.putStringValue(value: typeURL)
+    jsonEncoder.startField(name: "value")
+    jsonEncoder.append(text: value)
+    jsonEncoder.endObject()
+    return jsonEncoder.stringResult
+}
+
 public extension Message {
   /// Initialize this message from the provided `google.protobuf.Any`
   /// well-known type.

            if let m = message as? _CustomJSONCodable {
                // Serialize a Well-known type to JSON:
                let value = try m.encodedJSONString()
                return "{\"@type\":\"\(url)\",\"value\":\(value)}"
            } else {
                // Serialize a regular message to JSON:
                return try serializeAnyJSON(for: message, typeURL: url)

                if let messageType = Google_Protobuf_Any.wellKnownTypes[messageTypeName] {
                    let m = try messageType.init(unpackingAny: self)
                    let value = try m.jsonString()
                    return try serializeAnyJSON(wktValueJSON: value, typeURL: typeURL)
                }
                // Otherwise, it may be a registered type:
                if let messageType = Google_Protobuf_Any.knownTypes[messageTypeName] {
