I am attempting to create a class in vb.net from the below JSON example.
I am fairly new to JSON, and I am just having trouble figuring out the correct way of doing this. I have looked at numerous examples of how to do this but they are in much simpler formats than the one I am providing below.
LEVEL0({
"LEVEL1": [
{
"LEVEL2": [
{
"City": "Billings",
"State": "MO",
"Country": "US",
"Id": "1122334455",
"Percent": "39.10"
}
],
"City": "Billings",
"Country": "US",
"NumFound": "1",
"NumReturned": "1",
"State": "MO",
"Status": "Success"
}
],
"Status": "1"
});
I was thinking that this would be fairly easy, but what is causing me issues is that LEVEL2 is a list. It could return back multiple cities. So, it could return something like this within the [].
{"City": "Billings","State": "MO","Country": "US","Id": "1122334455","Percent": "39.10"},
{"City": "Fairmount","State": "MN","Country": "US","Id": "1177775","Percent": "64.10",}
So either way that portion needs to be a list, but then the portion below the list needs to be part of that class also. Where you see numFound.
I am guessing this is poorly worded, but I am struggling to find a good example of how this would be done. Any direction or advice on this would be greatly appreciated. I need to have the class correctly formatted so when I deserialize into the class it works without error.
If you’re using a webservice of some sort, it should automatically bind for you if you are using an object that has all of these properties. Something like:
Then in your webservice, have it accept a parameter of type
WrapperClass