I need to get json data from an external domain. I used webrequest to get the response from a website. heres the code:
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);
this way i am getting an output like this
[{"hitCount":0,"imageURL":"","query":"Atrix h\u00E5ndcreme Dobbeltvirkende /100 Ml","type":"productName"},{"hitCount":0,"imageURL":"","query":"V\u00E6gur magnetisk attraction","type":"productName"},{"hitCount":0,"imageURL":"","query":"Bic kuglepen Atlantis , bl\u00E5","type":"productName"},{"hitCount":0,"imageURL":"","query":"Laminering AT1256 31cm x30m A3","type":"productName"}]
I want to get this output data in JSON object format, that i can use this in my java script functions. i think the output data is in inappropriate format because i have used streamreader function to get data.is there any idea to solve this issue?
This data can be converted to json format using jQuery.parseJSON.
var obj = JSON.parse(data);
then we can access data like
obj[0].id
thanks to all.