0
[
["Received", "by luna.mailgun.net with SMTP mgrt 8734663311733; Fri, 03 May 2013 18:26:27 +0000"],
["Content-Type", ["multipart/alternative", {"boundary": "eb663d73ae0a4d6c9153cc0aec8b7520"}]],
["Mime-Version", "1.0"], ["Subject", "Test bounces webhook"],
["From", "Bob <[email protected]>"],
["To", "Alice <[email protected]>"],
["Message-Id", "<[email protected]>"],
["List-Unsubscribe", "<mailto:u+na6tmy3ege4tgnldmyytqojqmfsdembyme3tmy3cha4wcndbgaydqyrgoi6wsz[email protected]rs19930.mailgun.org>"],
["X-Mailgun-Sid", "WyIwNzI5MCIsICJhbGljZUBleGFtcGxlLmNvbSIsICI2Il0="],
["X-Mailgun-Variables", "{\"my_var_1\": \"Mailgun Variable #1\", \"my-var-2\": \"awesome\"}"],
["Date", "Fri, 03 May 2013 18:26:27 +0000"], ["Sender", "[email protected]"]
]
我把這個作爲郵件頭來自mailgun。我需要將這個頭解析成json。我試過JObject.Parse(message_headers)
和JArray.Parse(message_headers)
。但它不起作用。我無法解析由MailGun發送給Json的消息頭
當我刪除["X-Mailgun-Variables", "{\"my_var_1\": \"Mailgun Variable #1\", \"my-var-2\": \"awesome\"}"]
這似乎工作。
請讓我知道我做錯了什麼。
沒錯。你發佈的行不是JSON。 – esskar
'JArray.Parse()'適合我。請參閱https://dotnetfiddle.net/eLpjof。如果你事先不瞭解JSON的結構,[JToken.Parse()'](http://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_Linq_JToken_Parse.htm)是最安全的。 – dbc