Reputation: 2563
I will be using the following code to get json from a request.
Dim url As String = urlbuilder.ToString
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
Dim o As JObject = JObject.Parse(reader.ReadToEnd)
reader.Close()
response.Close()
I've checked this out and the o (JObject) has the information.
I now need to play around with this data but in order not to incur costs while developing (the data is from a paid service) I have a sample of the output that I've save as a file. How do I amend the above code so that I temporarily read in the file instead of process a response. Ideally I would want it still as an JObject.
Upvotes: 1
Views: 10711
Reputation: 129777
To read from a file on disk, replace your code with this:
Dim json As String = File.ReadAllText(@"c:\wherever\whatever.txt")
Dim o As JObject = JObject.Parse(json)
Upvotes: 1