HTTP请求...解析响应 [英] HTTP Request ... Parse the response
问题描述
我会尽量做到这一点。我已经设置了代码来发出http请求。它工作,请求,我没有收到错误。但是,我尝试解析响应时遇到错误。而不是张贴我所拥有的,我只会
问这个。根据以下回复你会如何解析它?我觉得它似乎是JSON。我在请求中得到null,所以它失败了。我现在不知道如何最好地问这个问题我正在打字。 我将开始发布http响应I
猜测。我并不反对放弃我没有工作的所有代码并从头开始......
所以,如果你这样做,你会怎么做?
当我通过我的应用程序运行时,我什么都没得到。我试图将其解析为JSON并且我收到此错误
无效的JSON原语:System.Net.HttpWebResponse。'
这是Burp Suite截获的回复
HTTP / 1.1 200 OK
日期:星期二,2018年7月10日23:15:10 GMT
strict-transport-security:max-age = 31536000; includeSubDomains
X-Powered-By:Servlet / 3.0
缓存控制:必须重新验证,max-age = 0
到期:星期二,2017年7月10日23:25:10 GMT
关闭:关闭
内容类型:application / json
内容 - 语言:zh- US $
X-Iinfo:5-126711005-126711029 NNNN CT(76 79 0)RT(1531264508915 133)q(0 0 2 -1)r(3 3)U2
X-CDN:Incapsula
内容长度:361
$
{" success":true," data":{ "部分":[[" 102116330200","PIN,PISTON","13.49","6.70",""","In Stock",[" 1,"," 4英寸," 0"],"",""," 2018年7月10日"],[" 102116330200"," PIN,活塞和QUOT;," 13.49"," 6.70",",",","在
股票",["1","4","0"," 10-2018"],[" 102116330200"," PIN,活塞和QUOT;," 13.49",&q uot; 6.70",""," In Stock",[" 1," 4"," 0"],",""," 07-10- 2018年""],"仓库":["威斯康星州","佐治亚州","加利福尼亚州"]}}
显示您解析结果的代码。您可能应该使用 StreamReader.ReadToEnd 从
HttpWebResponse.GetResponseStream 中提取JSON字符串,然后解析它。
I will try to make this short as possible. I already have code set to make an http request. it works and the request is made and I don't receive errors. I do however get errors attempting to parse the response. Instead of posting what I have I will just ask this. Based on the below response how would you parse it? It appears to be JSON I think. I get null back in my request so it fails. I am not sure how to best ask this question now that I am typing it. I will start with posting the http response I guess. I am not opposed to ditching all the code I have that doesnt work and starting from scratch...
So if you were doing this how would you do it?
When I run it through my app I get nothing. I tried to parse it as JSON and I get this error
Invalid JSON primitive: System.Net.HttpWebResponse.'
This is the response as intercepted by Burp Suite
HTTP/1.1 200 OKDate: Tue, 10 Jul 2018 23:15:10 GMT
strict-transport-security: max-age=31536000; includeSubDomains
X-Powered-By: Servlet/3.0
Cache-Control: must-revalidate, max-age=0
Expires: Tue, 10 Jul 2018 23:25:10 GMT
Connection: close
Content-Type: application/json
Content-Language: en-US
X-Iinfo: 5-126711005-126711029 NNNN CT(76 79 0) RT(1531264508915 133) q(0 0 2 -1) r(3 3) U2
X-CDN: Incapsula
Content-Length: 361
{"success":true,"data":{"parts":[["102116330200","PIN,PISTON","13.49","6.70","","In Stock",["1","4","0"],"","","07-10-2018"],["102116330200","PIN,PISTON","13.49","6.70","","In Stock",["1","4","0"],"","","07-10-2018"],["102116330200","PIN,PISTON","13.49","6.70","","In Stock",["1","4","0"],"","","07-10-2018"]],"warehouses":["Wisconsin","Georgia","California"]}}
Show your code that parses the result. You probably should extract the JSON string from HttpWebResponse.GetResponseStream using StreamReader.ReadToEnd, then parse it.
这篇关于HTTP请求...解析响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!