I really need help creating classes for this JSON, I need to eventually loop through and add each name (example: 20th Anniversary Pack 1st Wave) and its corresponding code (example: 20AP) to a database, but to do that I need to deserialize this first and I cant work out how to create the classes, usually I generate them but when I tried that it did not work, tia
Here is part of my JSON string:
{
"status": "success",
"setsAbbreviations": {
"20th Anniversary Pack 1st Wave": ["20AP"],
"20th Anniversary Pack 2nd Wave": ["20AP"],
"Beginner's Edition 1 (2011)": ["BE01"],
"Beginner's Edition 2 (2011)": ["BE02"],
"Booster Chronicle": ["BC"],
"Booster R2": ["B2"],
}
}
This is the code I have tried:
Public Class root3
Public Property status As String
Public Property setsAbbreviations As String()
End Class
And this is the error: 'An unhandled exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll
Additional information: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.String[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'setsAbbreviations['20th Anniversary Pack 1st Wave']', line 1, position 74.'
it did not workis a feeble problem description. As is, this is just asking for someone to write code for you and thats not what the site is about.[ ... ]means an array, but all those codes are just an array of 1; also the20th ...entry has the same code for 1 and 2nd wave. The definition forsetsAbbreviationsis not correct to start with - VS and none of the other class creating robots made that - I'd change the definition to aDictionary(of String, String())