我需要从外部域获取 json 数据。我使用 webrequest 从网站获取响应。继承人的代码:
var search = umbraco.library.Request("search");
string Url = "http://ff.ss.dk/Suggest.ff?username=us&password=pass&channel=dk&format=JSON&query="+search;
WebRequest webRequest = WebRequest.Create(Url);
WebResponse response = webRequest.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
这样我得到这样的输出
[{"hitCount":0,"imageURL":"","query":"Atrix h\u00E5ndcreme Dobbeltvirkende /100 Ml","type":"productName"},{"hitCount":0,"imageURL": "","query":"V\u00E6gur 磁吸","type":"productName"},{"hitCount":0,"imageURL":"","query":"Bic kuglepen Atlantis , bl\u00E5 ","type":"productName"},{"hitCount":0,"imageURL":"","query":"Laminering AT1256 31cm x30m A3","type":"productName"}]
我想以 JSON 对象格式获取此输出数据,我可以在我的 java 脚本函数中使用它。我认为输出数据的格式不合适,因为我使用了流式读取器功能来获取数据。有什么想法可以解决这个问题吗?