When using a JSON parser, you should not need to directly manipulate the JSON string (that is the job of the parser), nor parse the JSON more than once (the data is already in memory from the first parse). So you are right, what you are doing is not the best way to extract the data.
Here is an example of how you can extract the user_id
and other result data from the JSON using the LINQ-to-JSON API (i.e. JObjects / JTokens). Because results
is an array in the JSON, I'm assuming there might not always be just one result, so I will use a loop here.
' load all the JSON data into a JObject
Dim p1 As JObject = JObject.Parse(json)
' loop over the "results" array to get each child object (result)
For Each result As JToken In p1("results").Children()
' extract the data from each result
Dim userId As Integer = result("user_id").Value(Of Integer)()
Dim loginName As String = result("login_name").ToString()
Dim creationTsz As Long = result("creation_tsz").Value(Of Long)()
' the feedback info is one level further down
Dim feedback As JToken = result("feedback_info")
Dim feedbackCount As Integer = feedback("count").Value(Of Integer)()
Dim feedbackScore As Integer = feedback("score").Value(Of Integer)()
' do something with the data; perhaps write it to the console
Console.WriteLine("User ID: " + userId.ToString())
Console.WriteLine("Login Name: " + loginName.ToString())
Console.WriteLine("Creation TSZ: " + creationTsz.ToString())
Console.WriteLine("Feedback Count: " + feedbackCount.ToString())
Console.WriteLine("Feedback Score: " + feedbackScore.ToString())
Console.WriteLine()
Next