JSON Serailizing with VB.NET - json

I am trying to serialise some JSON from nested objects into a string. However I am having issues with the arrays within the objects
Class RequestTaxes
Public Property usrname As String
Public Property pswrd As String
Public Property isAudit As Boolean
Public Property currn As String
Public Property lines() As TaxLines
End Class
Class TaxLines
Public Property debCredIndr As Integer
Public Property goodSrvCd As String
Public Property grossAmt As Double
Public Property lnItmId As String
Public Property qnty As Double
Public Property trnTp As Integer
Public Property accntDt As DateTime
Public Property custVendName As String
Public Property custVendCd As String
Public Property orgCd As String
End Class
However when I try to pass the serialised string to the API It is refused because the square brackets around the "lines" list are missing.
Does anyone know who to put these in when using Newtonsoft?
Dim Settings As New JsonSerializerSettings
Settings.NullValueHandling = NullValueHandling.Ignore
Dim InputString As String = JsonConvert.SerializeObject(message, Settings)
"message" contains a populated object of type RequestTaxes

I think you have your property declarations a bit off.
Public Property lines() As TaxLines
is equivalent to
Public Property lines As TaxLines
meaning that your TaxLines is only a single instance, not an array.
You need to add parantheses at the end of the line like so:
Public Property lines() As TaxLines()

I actually needed to do
Public Property lines As List(of TaxLines)

Related

How to create and read a JSON file in vb.net

I first created my JSON class, here is the code:
Public Class Fich
<JsonProperty("title")>
Public Property Title As String
<JsonProperty("name")>
Public Property Name As String
<JsonProperty("charge")>
Public Property Charge As String
<JsonProperty("institute")>
Public Property Institute As String
<JsonProperty("celebration")>
Public Property Celebration As String
End class
Public Class Prenommer
<JsonProperty("fiches")>
Public Property Fiches As Fich()
End Class
Then my data string:
Dim rawJson As String = "{""Title"":""TextBox2.Text"",""Name"":""TextBox1.Text"",""Charge"":""TextBox4.Text"",""Institute"":""TextBox15.Text"",""Celebration"":""TextBox5.Text""}"
On this string, I would like it to take into account the TextBox text of my main sheet. For the moment I can't do it, I don't see what I can replace the quadruple quotes that surround them!
And above all, if I can understand the method to achieve this, how to create and read the JSON file with the data from the TextBoxs!
Claude

How to read json return string?

Having trouble to read json return in a useful way
Searching "all over" to find how to create classes and how to de-serialize json return
This is the json return:
[[{"metadata":{},"contentType":0,"contentId":0,"objectName":"Mi","objectId":"1","classId":"118"},
{"metadata":{},"contentType":0,"contentId":0,"objectName":"BA","objectId":"224445","classId":"103"},
{"metadata":{},"contentType":0,"contentId":0,"objectName":"1","objectId":"239011","classId":"104"},
{"metadata":{},"contentType":0,"contentId":0,"objectName":"1","objectId":"239309","classId":"105"}]]
Tried Visual Studio (VB.net) Paste Special to create json classes, but I can't seem to get my head around how to use it. Using Newtonsoft.Json.
These are the classes, how do I deserialize json and make it useful?
Public Class Rootobject
Public Property Property1()() As Class1
End Class
Public Class Class1
Public Property metadata As Metadata
Public Property contentType As Integer
Public Property contentId As Integer
Public Property objectName As String
Public Property objectId As String
Public Property classId As String
End Class
Public Class Metadata
End Class
Your JSON is an array of arrays of Class1 objects, so you need to deserialize to that.
Dim data As Class1()() = JsonConvert.DeserializeObject(Of Class1()())(json)
You don't actually need the Rootobject class here.
Working demo: https://dotnetfiddle.net/1JuaYk

JSON Format Deserialize Error

I am new to manipulating JSON format data retrieved through an Web API. I'm using Newtonsoft.Json.JsonConvert to deserialize and assign to datatable.
This is the JSON data I am trying to get into a datatable.
[{
"classDesc":"SIDEWALK,DRIVEWAY,CURB",
"classCode":"EH",
"legend":"017",
"isActive":"Y",
"atrSpaCityDistrictId":"00D17209F8F25F6D4A00011302",
"atrSpaCitieDistrict":{
"cityDistrict":"",
"isActive":"1",
"atrSpaClassLegends":null,
"id":"00D17209F8F25F6D4A00011302"
},
"id":"00D1748B8DA0AB0A7400011202"
}]
I have created the below classes
Public Class RootObject
Public Property classDesc As String
Public Property classCode As String
Public Property id As Integer
Public Property legend As Integer
Public Property isActive As String
Public Property atrSpaCityDistrictId As Integer
Public Property atrSpaCitieDistrict As List(Of Result) End Class
Public Class Result
Public Property cityDistrict As String
Public Property isActive As Integer
Public Property atrSpaClassLegends As List(Of Legend)
Public Property id As Integer
End Class
Public Class Legend
End Class
Below is my VB.Net code:
Dim table As DataTable Dim client As New HttpClient() client.BaseAddress = New Uri("http://localhost:5000/") client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json"))
Dim response As HttpResponseMessage = client.GetAsync("api/spaclasslegend").Result
If response.IsSuccessStatusCode Then
Dim json As String = response.Content.ReadAsStringAsync().Result table = JsonConvert.DeserializeObject(Of DataTable)(json)
End If
Getting below error
"Cannot deserialize the current JSON array (e.g. [1,2,3]) into type
'Alco.APTIS.Services.RootObject' because the type requires a JSON
object (e.g. {"name":"value"}) to deserialize correctly."
I have tried different ways to fix this using stackoverflow.com and finally posting here for help.
You have two unrelated issues.
Firstly, your root object doesn't match your JSON. If I copy your JSON into a code generator such as http://jsonutils.com/, I get the following, using a List(Of Legend) for the null atrSpaClassLegends property:
Public Class AtrSpaCitieDistrict
Public Property cityDistrict As String
Public Property isActive As String
Public Property atrSpaClassLegends As List(Of Legend)
Public Property id As String
End Class
Public Class RootObject
Public Property classDesc As String
Public Property classCode As String
Public Property legend As String
Public Property isActive As String
Public Property atrSpaCityDistrictId As String
Public Property atrSpaCitieDistrict As AtrSpaCitieDistrict
Public Property id As String
End Class
Public Class Legend
End Class
Having done this, it is now possible to deserialize your JSON into a List(Of RootObject):
Dim root = JsonConvert.DeserializeObject(Of List(Of RootObject))(jsonString)
Note you must deserialize as a List(Of RootObject) (or similar .Net collection such as an array) since your top level JSON container is a JSON array -- an ordered comma-separated sequence of values surrounded by [ and ]. This is explained in the Json.NET Serialization Guide. Sample fiddle.
Secondly, despite having created these types, in the code shown in your question you are not using them at all! Instead, you are deserializing to a DataTable. And unfortunately the atrSpaCitieDistrict property is a nested object:
{
"atrSpaCitieDistrict": {
"cityDistrict": "",
"isActive": "1",
"atrSpaClassLegends": null,
"id": "00D17209F8F25F6D4A00011302"
},
}
Json.NET does not support automatically deserializing column values that are complex objects into untyped data tables, and will throw an exception if one is encountered. Instead, you would need to deserialize into a typed data table. However, this may be a typo in your question; the exception error message indicates you are actually trying to deserialize into an object of type Alco.APTIS.Services.RootObject and not a DataTable.

convert object json to object vb .net

Hello I need to convert this objetct to vb.
{"user":
[
{"name":"CompanyName"},
{"password":"CompanyPassword"},
{"email":"mail#company.com"},
{"name":"UserName"},
{"email":"user#mail.com"}
]
}
I try with this:
Public Class InfoObjUser
Public Property name As String
Public Property password As String
Public Property email As String
End Class
Public Class ObjUser
Public Property user As New List(Of InfoObjUser)
End Class
but when I go to serialize json object created in vb
I see that there are no curly brackets.
Also in vb I can't add {"name":"UserName"},{"email":"user#mail.com"}
because they are already present.
Take a look at this: JSON Serialization in .Net.
You need to add the System.Runtime.Serialization as reference to your project, and then set up a serializer object in your code. You also need to tag, which fields in your class match your JSON code.
This would be your class setup:
<DataContract>
Public Class InfoObjUser
<DataMember(Name:="Name")>
Public Property name As String
<DataMember(Name:="Password")>
Public Property password As String
<DataMember(Name:="Email")>
Public Property email As String
End Class
<DataContract>
Public Class ObjUser
<DataMember>
Public Property user As New List(Of InfoObjUser)
End Class
And a Json reader class for that would look like this:
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Json
Public Class JsonReader
Public Shared Function FromString(Of T)(ByVal input As String) As T
Dim serializer As New DataContractJsonSerializer(GetType(T))
Dim memStream As New MemoryStream()
Dim sw As New StreamWriter(memStream)
sw.Write(input)
sw.Flush()
memStream.Position = 0
Dim returnObj As T = CType(serializer.ReadObject(memStream), T)
Return returnObj
End Function
End Class
And finally, you can call this class like this:
Dim jsonString ' = ...Input string here
Dim user As ObjUser = JsonReader.FromString(Of ObjUser)(jsonString)
However, it is not possible to have the name for two different data objects, as the serializer would not know where to map them to, as it goes by Object name.
I don't know how established this data structure already is, but if it's possible, I would suggest you to change the duplicated names, as no real mapping can occur when doing so programmatically.
<DataMember(Name:="UserName")>
Public Property username As String
<DataMember(Name:="UserEmail")>
Public Property usermail As String
If you would add something like this to your data model class and rename the field names in your Json, then it would work.

Json parsing issue in vb.net

I need to parse following json in vb.net. I'm using Json.net but do not know how to do it.
Problem occurs in scan result contains scan detail that conaints anti virus name with some detail. but all the anti-virus is object not an array. So please any body tell me how to do it.
{"file_id":"aaa60a443e3a4426944da9e6fe8a3f3c","scan_results":{"scan_details":{"AegisLab":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"Agnitum":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"Ahnlab":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-24T00:00:00Z","scan_time":1.0},"Antiy":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"AVG":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"Avira":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"BitDefender":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"ByteHero":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"ClamWin":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"CYREN":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"DrWebGateway":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"Emsisoft":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"ESET":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"Filseclab":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"Fortinet":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"F-prot":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"F-secure":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"GFI":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"Hauri":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"Ikarus":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"Jiangmin":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"K7":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-20T00:00:00Z","scan_time":1.0},"Kaspersky":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"Lavasoft":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"McAfee-Gateway":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"Microsoft":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"NANO":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"nProtect":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"Preventon":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"QuickHeal":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"Sophos":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"STOPzilla":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-21T00:00:00Z","scan_time":1.0},"SUPERAntiSpyware":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"Symantec":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"Tencent":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"TotalDefense":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"TrendMicro":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-21T00:00:00Z","scan_time":1.0},"TrendMicroHouseCall":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-21T00:00:00Z","scan_time":1.0},"VirIT":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-20T00:00:00Z","scan_time":1.0},"VirusBlokAda":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-20T00:00:00Z","scan_time":1.0},"Xvirus":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-23T00:00:00Z","scan_time":1.0},"Zillya!":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-22T00:00:00Z","scan_time":1.0},"Zoner":{"scan_result_i":0,"threat_found":"","def_time":"2015-02-18T00:00:00Z","scan_time":1.0}},"rescan_available":true,"data_id":"32fe182492834b6f88b1d95f6a14c886","scan_all_result_i":0,"start_time":"2015-02-23T13:10:55.549Z","total_time":1.0,"total_avs":43,"progress_percentage":100,"in_queue":0,"scan_all_result_a":"Clean"},"file_info":{"file_size":0,"upload_timestamp":"2015-02-23T00:40:41.029Z","md5":"D41D8CD98F00B204E9800998ECF8427E","sha1":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","sha256":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","file_type_category":"O","file_type_description":"empty","file_type_extension":"-","display_name":"C:\\testy.xml"},"data_id":"32fe182492834b6f88b1d95f6a14c886"}
First, you need to create a class (or multiple) that can represent the data you want to deserialize.
Looking at the input string you provided, you need a class for FileInfo, ScanDetail, ScanResults and one for the root (let's call it Scan).
It's simply a matter of mapping the JSON keys to a class property (and a dictionary for ScanDetail, since you probably don't want a property for each of it).
So, your classes should look like this:
public class Scan
public property file_id() as string
public property scan_results() AS ScanResults
public property file_info() as FileInfo
public property data_id() as string
End Class
public class ScanResults
public property scan_details As Dictionary(Of string, ScanDetail)
Public Property rescan_available() As Boolean
Public Property data_id() As String
Public Property scan_all_result_i() As Integer
Public Property start_time() As String
Public Property total_time() As Double
Public Property total_avs() As Integer
Public Property progress_percentage() As Integer
Public Property in_queue() As Integer
Public Property scan_all_result_a() As String
End Class
public class ScanDetail
public property scan_result_i() As integer
public property threat_found() as string
public property def_time() as string
public property scan_time() as string
End class
Public Class FileInfo
Public Property file_size() As Integer
Public Property upload_timestamp() As String
Public Property md5() As String
Public Property sha1() As String
Public Property sha256() As String
Public Property file_type_category() As String
Public Property file_type_description() As String
Public Property file_type_extension() As String
Public Property display_name() As String
End Class
Now the deserializing is as easy as
Dim details = NewtonSoft.JSon.JsonConvert.DeserializeObject(Of Scan)(your_json_string)
To get all threat_found values, you can easily query the result:
Dim threats = details.scan_results.scan_details.Select(Function(kvp) kvp.Value.threat_found) _
.Where(Function(t) Not String.IsNullOrWhiteSpace(t)) _
.ToList()
Here is how to deserialize that JSON string assuming you have referenced Json.Net. What you get is a dynamic object with property names the same as the JSON property names. If you were to create a Class with the correct properties you could also deserialize into that specific type and you would have the benefit of strong typing. Put a break point after this code and run with Debug. Look in the Locals window and you can inspect "theobj"'s properties.
Dim obj As String = "{""file_id"":""aaa60a443e3a4426944da9e6fe8a3f3c"",""scan_results"":{""scan_details"":{""AegisLab"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""Agnitum"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""Ahnlab"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-24T00:00:00Z"",""scan_time"":1.0},""Antiy"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""AVG"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""Avira"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""BitDefender"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""ByteHero"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""ClamWin"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""CYREN"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""DrWebGateway"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""Emsisoft"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""ESET"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""Filseclab"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""Fortinet"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""F-prot"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""F-secure"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""GFI"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""Hauri"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""Ikarus"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""Jiangmin"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""K7"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-20T00:00:00Z"",""scan_time"":1.0},""Kaspersky"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""Lavasoft"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""McAfee-Gateway"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""Microsoft"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""NANO"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""nProtect"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""Preventon"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""QuickHeal"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""Sophos"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""STOPzilla"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-21T00:00:00Z"",""scan_time"":1.0},""SUPERAntiSpyware"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""Symantec"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""Tencent"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""TotalDefense"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""TrendMicro"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-21T00:00:00Z"",""scan_time"":1.0},""TrendMicroHouseCall"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-21T00:00:00Z"",""scan_time"":1.0},""VirIT"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-20T00:00:00Z"",""scan_time"":1.0},""VirusBlokAda"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-20T00:00:00Z"",""scan_time"":1.0},""Xvirus"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-23T00:00:00Z"",""scan_time"":1.0},""Zillya!"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-22T00:00:00Z"",""scan_time"":1.0},""Zoner"":{""scan_result_i"":0,""threat_found"":"""",""def_time"":""2015-02-18T00:00:00Z"",""scan_time"":1.0}},""rescan_available"":true,""data_id"":""32fe182492834b6f88b1d95f6a14c886"",""scan_all_result_i"":0,""start_time"":""2015-02-23T13:10:55.549Z"",""total_time"":1.0,""total_avs"":43,""progress_percentage"":100,""in_queue"":0,""scan_all_result_a"":""Clean""},""file_info"":{""file_size"":0,""upload_timestamp"":""2015-02-23T00:40:41.029Z"",""md5"":""D41D8CD98F00B204E9800998ECF8427E"",""sha1"":""DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"",""sha256"":""E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"",""file_type_category"":""O"",""file_type_description"":""empty"",""file_type_extension"":""-"",""display_name"":""C:\\testy.xml""},""data_id"":""32fe182492834b6f88b1d95f6a14c886""}"
Dim theobj = JsonConvert.DeserializeObject(obj)
Thanks for your reply guys. I have done it by following code snippet
Dim jsonstring = IO.File.ReadAllText("C:\\Users\\Administrator\\Desktop\\json.txt")
Dim jo = Newtonsoft.Json.Linq.JObject.Parse(jsonstring)
Dim scanDetail = jo("scan_results")("scan_details")
Dim virusCount As Integer
virusCount = 0
For Each entry As Newtonsoft.Json.Linq.JProperty In scanDetail
entry.CreateReader()
Console.WriteLine(entry.Name)
For Each Val As Object In entry
Dim abc = Newtonsoft.Json.Linq.JObject.Parse(Val.ToString())
Dim threatFound As String = abc("threat_found")
Dim result As Integer = String.Compare(threatFound, "")
If result = -1 Then
virusCount = virusCount + 1
End If
Next
Next
If virusCount = 0 Then
Console.WriteLine("No Virus")
Else
Console.WriteLine("Virus")
End If