I am having trouble deserializing this JSON in VB.. I can only get hold of the value in each array but can't get the key which are the fieldnames in my tables. You will note that each object can vary in size which I can handle on deserializing..
can anyone help?
{
"MATRIX": [
{
"1": "FM",
"2": "4",
"3": "Floor type",
"4": "Standing water",
"5": "Property unsafe"
},
{
"1": "FM",
"2": "4",
"3": "Ceiling",
"4": "Mould spores",
"5": "Room/property still safe"
},
{
"1": "FL",
"2": "Basement",
"3": "1"
},
{
"1": "FL",
"2": "External",
"3": "7"
},
{
"1": "FL",
"2": "First Floor",
"3": "3"
},
{
"1": "FL",
"2": "Garden",
"3": "6"
},
{
"1": "FL",
"2": "Ground Floor",
"3": "2"
},
{
"1": "FL",
"2": "Second Floor",
"3": "4"
},
{
"1": "FL",
"2": "test 2",
"3": "9"
},
{
"1": "FL",
"2": "Third Floor",
"3": "5"
},
{
"1": "CA",
"2": "Bath",
"3": "Bathroom",
"4": "Bath"
},
{
"1": "CA",
"2": "Electrical",
"3": "Bathroom",
"4": "Bathroom Socket"
}
]
}
Thank you in advance,
D:)
Hi again.. I have tried the code from the second suggestion but cannot get the key and value for each item at the same time. I get the keys and then the values for each iteration of my string..
this is what I am doing. Please can you point out my error..
Dim json As String = "{""items"":[{""Name"":""John"",""Age"":""20"",""Gender"":""Male""},{""Name2"":""Tom"",""Age2"":""25"",""Gender2"":""Male""},{""Name3"":""Sally"",""Age3"":""30"",""Gender3"":""Female""}]}"
Dim jss = New JavaScriptSerializer()
Dim data = jss.Deserialize(Of Object)(json)
For i = 0 To 2
For Each key As String In data("items")(i).Keys
MsgBox(key)
Next
'For Each item As Dictionary(Of String, Object) In data("items")
For Each val As String In data("items")(i).Values
MsgBox(val)
Next
Next
Thank you again,
Derek.