Hello all,
I am trying to deserialise some JSON in Visual Basic.
However, I am having a bit of trouble. I am using Newtonsoft.Json.
But I seem to keep getting this error when I try to deserialise some JSON:
The JSON text:
{"id":"e7cc8ec97b294d2484843d330f136bbd","name":"iProgramIt","properties":[{"name":"textures","value":"eyJ0aW1lc3RhbXAiOjE0NzAyMDkwOTIzNzQsInByb2ZpbGVJZCI6ImU3Y2M4ZWM5N2IyOTRkMjQ4NDg0M2QzMzBmMTM2YmJkIiwicHJvZmlsZU5hbWUiOiJpUHJvZ3JhbUl0IiwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2Y3ZjZmMGU2YTJhM2Q2ZGI2OWE0YWZhOWZlZjI4ZWE0ZDU2ZjM3MTk5Mjc3Zjk1YzFkMmI1ZjBhYWE0ZTIifX19"}]}
The Error when I'm trying to deserialise it:
Newtonsoft.Json.JsonSerializationException was unhandled
HResult=-2146233088
Message=Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Minecraft_Report_Generator.Form1+PropertyX' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
The following is my code:
Public Class PropertyX
Public Property name As String
Public Property value As String
Public Property signature As String
End Class
Public Class Skins_Base
Public Property id As String
Public Property name As String
Public Property properties As PropertyX
End Class
Public Class UUID_basic
Public Property id As String
Public Property name As String
Public Property legacy As Boolean
Public Property demo As Boolean
End Class
Dim retrieveString As String = GETX(Basic_USER & TextBox1.Text)
Dim obj = JsonConvert.DeserializeObject(Of UUID_basic)(retrieveString)
Dim SkinsBase As String = GETX("https://sessionserver.mojang.com/session/minecraft/profile/" & obj.id)
Dim xObj = JsonConvert.DeserializeObject(Of Skins_Base)(SkinsBase)
The last line of that code is the one that is errored. Also, I have extracted the bits and pieces from my code relevant to this circumstance, so I realise that you cannot call functions, etc. from the class.
Thanks in advance,
-iProgramIt
What I have tried:
I have tried googling on the internet, but have found nothing matching my circumstance. I have tried looking through forums like this one, and several others. I have found nothing.