Question : Extract Objects from Stream

This is a small extract from a response stream.  I am using the code below.

I want to be able to extract the data from the stream.  Whats the easiest way to do this?

{"contacts":[
{"email":"[email protected]","firstName":"Collette","lastName":"Craig","prefix":null,"suffix":null,"fax":null,"phone":null,"street":"5 Clonliffe Park","street2":"Culmore","city":"L'DERRY","state":"L'Derry","postalCode":"BT48 8NT","createDate":"2010-07-20 10:15:15","status":"normal","bounceCount":"0","contactId":"13881205"},
{"email":"admin.belfast@centreni.org","firstName":"Les","lastName":"Allamby","prefix":null,"suffix":null,"fax":null,"phone":null,"street":"124 Donegall Street","street2":null,"city":"BELFAST","state":"Antrim","postalCode":"BT1 2GY","createDate":"2010-07-20 10:15:15","status":"normal","bounceCount":"0","contactId":"13881206"},
{"email":"admin@freeserve.co.uk","firstName":"Thomas","lastName":"McElroy","prefix":null,"suffix":null,"fax":null,"phone":null,"street":"Westcourt Centre","street2":"8-30 Barrack Street","city":"BELFAST","state":"Antrim","postalCode":"BT12 4AH","createDate":"2010-07-20 10:15:15","status":"normal","bounceCount":"0","contactId":"13881207"},
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Dim Request As System.Net.HttpWebRequest = ar.AsyncState
        Dim response As HttpWebResponse
        response = Request.GetResponse
        Dim s As Stream = response.GetResponseStream()
        Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
        Dim readStream As New StreamReader(s, encode)
        Dim Respon As String = ""
        Dim read(256) As [Char]

        ' Read 256 charcters at a time    .
        Dim count As Integer = readStream.Read(read, 0, read.Length)

        While count > 0
            Dim str As New [String](read, 0, count)
            Respon += str
            count = readStream.Read(read, 0, 256)
        End While

Answer : Extract Objects from Stream

you can use

sr.ReadToEnd();

i hope it will read whole data in one go

secondly

readStream.Readline()
Random Solutions  
 
programming4us programming4us