I need some help to create a JSON object from vb.net code using Newtonsoft

Job ID: 33895523

Budget: $10 – $30 USD

I have a VB.Net Web 2.0 API that produces a JSON object and that JSON object needs to be bulit using two different data sources. the end result needs to look like

{
"Member": {
"Last Name": "Ao",
"Email": "al@mu",
"PMID_List": "34872100,34699641,34415311,34341013"
},
"New_Publications": [{
"PMID": "34872100",
"citations": "1"
}, {
"PMID": "34415311",
"citations": "1"
}, {
"PMID": "27742762",
"citations": "304"
}]
}
I know that my JSON object are wrong below but it give you an idea of what I need. I just need some code to point me in the right direction. Create your own objects and build the JSON object so that it give me the output I need in a JavaScript AXIOS application.
Thank you



The Web API will call two functions and it will first return the person name and email information. So that will be built something like

Dim sb As StringBuilder = New StringBuilder()
Dim writer As JsonWriter = New JsonTextWriter(New StringWriter(sb))
writer.WriteStartObject()
writer.WritePropertyName("Member")
writer.WriteStartObject()
writer.WritePropertyName("Last Name")
writer.WriteValue(result.Last)

writer.WritePropertyName("Email")
writer.WriteValue(result.EmailList)
writer.WritePropertyName("PMID_List")
writer.WriteValue(pmidList)
writer.WriteEndObject()
writer.WriteEndArray()

Then the second array

needs to be added, something like

writer.WriteStartArray()

For Each pa In PubmedArticles
writer.WriteStartObject()
writer.WritePropertyName("PMID")
writer.WriteValue(pa.pmid)
writer.WritePropertyName("citations")
writer.WriteValue(pa.citations)
writer.WriteEndObject()
Next

writer.WriteEndArray()
writer.Close()


Dim response As HttpResponseMessage = New HttpResponseMessage(HttpStatusCode.OK)
response.Content = New StringContent(sb.ToString, Encoding.UTF8, "application/json")

Return response
Related categories: JavaScript C# Programming ASP.NET VB.NET JSON