I need to parse Json using VB.NET using the Newtonsoft Json.Net library
Json Data --------- { "CC": " sample.cc@emailDomain.com ", "CcFull": [ { "Email": " sample.cc@emailDomain.com ", "Name": "John Sample" }, { "Email": " another.cc@emailDomain.com ", "Name": "Mike Sample" } ], "FromFull" : { "Email": " myUser@theirDomain.com ", "Name": "John Doe" } }
I can get a valid JObject this way:
Dim o As JObject = JObject.Parse(strJson)
Then I can get a list of JTokens and iterate over them and easily get the values ββof the root element - but how to get Child entries for CcFull?
Dim results As List(Of JToken) = o.Children().ToList For Each item As JProperty In results item.CreateReader() Select Case item.Name Case "CC" dim strCC = item.Value.ToString Case "CcFull" 'This has children (Email and Name) End Select Next
It looks like I could use a JArray or parse item.value - but the syntax eludes me.
I donβt want to configure the whole strongly typed model in VB and do automatic deserialization - prefer more as a dynamic way to do it in C # - or it is advisable to simply iterate over n children for CcFull node and break down enter values ββfor Email and Name and put them in the general list.
There seems to be no good examples of VB.NET in SO or Google.
C # has completely simple ways to do this, but I'm stuck in VB.NET for this project.
Thank you people
source share