1

Sorry but I'm at a loss. I'm trying to loop the following JSON object using Newtonsoft so that I can process some code

      [{"FirstName":"Andrea","Middlename":"M.","LastName":"Smith"},{"FirstName":"Ronald","Middlename":"E.","LastName":"Jones"}]

What I need is a simple loop that will read the names and send to a database. So I want to

    For  .....
    Dim FirstName as string = 
    Dim Middlename =""
    Dim LastName = ""

    Send to data base FirstName + " " + MiddleName + " " + LastName
    Loop

Thanks for the help and if this is listed somewhere else I have not been able to find it

2
  • Search for “newtonsoft json deserialize array vb.net” and you’ll find plenty of examples. Commented Feb 20, 2018 at 21:28
  • stackoverflow.com/a/28400404/125981 perhaps? Commented Feb 20, 2018 at 21:37

1 Answer 1

2

Worked out my own answer. First created a class

       Public Class Person
       Public FirstName As String
       Public MiddleName As String
       Public LastName As String
       End Class

Then

     Dim JObject = JsonConvert.DeserializeObject(Of Person())(JSON)

Then

Looped it

        For i = 0 To JObject.Length - 1
        firstname = JObject(i).FirstName
        Next
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.