Pav*_*sky 0 .net c# regex json
我有一个相当简单的问题,出于某种原因,我可以找到使用 SO 和 Google 的帮助。我收到一个 JSON 回复,如下所示:
"{
\"data\": [
{
\"type\": \"gif\",
\"id\": \"FiGiRei2ICzzG\",
\"url\": \"http: //giphy.com/gifs/funny-cat-FiGiRei2ICzzG\",
\"bitly_gif_url\": \"http: //gph.is/1fIdLOl\",
\"bitly_url\": \"http: //gph.is/1fIdLOl\",
\"embed_url\": \"http: //giphy.com/embed/FiGiRei2ICzzG\",
\"username\": \"\",
\"source\": \"http: //tumblr.com\", etc........
Run Code Online (Sandbox Code Playgroud)
所以它是一个标准的 JSON,但带有 \ 转义字符。现在我试图删除这些转义字符以解析 JSON 中的数据。尝试了字符串的 .replace 和其他一些解决方案,但出于某种原因,我仍然使用转义字符..谢谢!这是我用来做请求的代码
public static void GetRequest()
{
string sFullURL = "http://api.giphy.com/v1/gifs/search?q=";
string sSearchTerm = "funny+cat";
string sContent;
string sAPIKey = "&api_key=dc6zaTOxFJmzC";
string sLimit = "&limit=1";
string sFullRequest = "http://api.giphy.com/v1/gifs/search?q=funny+cat&api_key=dc6zaTOxFJmzC";
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(string.Format(sFullURL + sSearchTerm + sAPIKey + sLimit));
WebReq.Method = "GET";
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
System.Diagnostics.Debug.WriteLine(WebResp.StatusCode);
System.Diagnostics.Debug.WriteLine(WebResp.Server);
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
sContent = _Answer.ReadToEnd();
sContent = Regex.Replace(sContent, @"\\", "");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1775 次 |
| 最近记录: |