I have consume Survey data via SSE Stream
that gives me each persons answers line by line with this format for Survey X
:
{"data":["4482359","12526","5","5","","Yes, that is right","1"]}
I read it into a List(of String)
using Streamreader
Dim sr As StreamReader = New StreamReader(stream)
Dim myList As List(Of String) = New List(Of String)
While sr.Peek >= 0
myList.Add(sr.ReadLine())
End While
Now I want to deserialize the strings so I get the entries into properties of a class (let us call it tmpUserData
) that I can access. I have tried this using Newtonsoft.Json
:
Dim tmpUserData As Object = JsonConvert.DeserializeObject(Of Object)(myList(i))
but looking into tmpUserData
the deserialization does not split the entries as
(1) User1
(1) "4482359"
(2) "12526"
(3) "5"
(4) ""
...
(2) User1
(1) "5847895"
(2) "33568"
(3) "6"
(4) "2"
...
but instead it just put everything into one entry
(1) "4482359","12526","5","5","","Yes, that is right","1"
The reason why I cannot just write a class and put the data into it like
JsonConvert.DeserializeObject(myclass)(myList(i))
is that this has to be dynamically since the number and structure of strings differs for different surveys. So Survey Y
might looks like:
{"data":["Peter","Jackson","Albert Street","5","","1"]}
Could anyone help me get what I am looking for so the entries of each Survery Particpant are properly deserialized? C#
Solution is welcome as well.