I have the line of code that I want which is:
mid= jToken.Value<double?>("mid") ?? 100;
in C# but I need it in VB.NET I got it from Get value from JToken that may not exist (best practices)
But I'm have a bit of trouble in converting that to the proper syntax in VB. I've tried
Dim mid As String = item.Value(Of String)("mid") ?? ""
But it does not like the?
What I would like is to end with an empty string or blank if the value is not in the object. This is my full code
Dim obj As JObject = JObject.Parse(respHTML)
Dim records As JArray = DirectCast(obj("records"), JArray)
For i As Integer = 0 To records.Count - 1
Dim item As JObject = DirectCast(records(i), JObject)
Dim pmid As Integer = item("pmid").Value(Of Integer)
Dim pmcid As String = item("pmcid").Value(Of String)
Dim doi As String = item("doi").Value(Of String)
' Dim mid As String = item("mid").Value(Of String)
Dim mid As String = item.Value(Of String)("mid") ?? ""
MessageBox.Show(pmid.ToString + " " + pmcid + " " + doi + " " + mid)
Next