How to deserialize this json file in vb.net with json.net? -
i using json.net library , have json file want deserialize:
{ "jsonversion": 3, "levelmasteryscore3": 70000, "boosts": { "preboostsupergems": { "enabled": 1, "jsonversion": 1 }, "preboostthreemoves": { "enabled": 1, "jsonversion": 1 }, "preboostcolorsplash": { "enabled": 1, "jsonversion": 1, "excludedcolors": [ "g" ] }, "jsonversion": 1 }, "name": "0017", "movelimitobjective": { "movelimit": 19, "jsonversion": 1 }, "gemspawnchance": { "r": 20, "b": 20, "g": 0, "p": 20, "y": 20 }, "levelmasteryscore1": 20000, "board": { "tiles": [ [ "x", "x", "x", "x", "x", "x", "x" ], [ "x", "x", "x", "x", "x", "x", "x" ], [ "x", "x", "x", "x", "x", "x", "x" ], [ "a", "a", "a", "a", "a", "a", "a" ], [ "a", "e", "a", "e", "a", "e", "a" ], [ "a", "j1", "a", "j1", "a", "j1", "a" ], [ "a", "a", "a", "a", "a", "a", "a" ], [ "j1", "j1", "j1", "e", "j1", "j1", "j1" ], [ "j1", "j1", "j1", "j1", "j1", "j1", "j1" ] ], "visiblesize": { "width": 7, "jsonversion": 1, "height": 9 }, "pieces": [ [ "@", "@", "@", "@", "@", "@", "@" ], [ "@", "@", "@", "@", "@", "@", "@" ], [ "@", "@", "@", "@", "@", "@", "@" ], [ "d", "d", "d", "d", "d", "d", "d" ], [ "d", " ", "d", " ", "d", " ", "d" ], [ "d", " ", "d", " ", "d", " ", "d" ], [ "d", "d", "d", "d", "d", "d", "d" ], [ " ", " ", " ", " ", " ", " ", " " ], [ " ", " ", " ", " ", " ", " ", " " ] ], "jsonversion": 2 }, "levelmasteryscore2": 50000, "jellyobjective": { "jellytoremove": 16, "jsonversion": 1 } }
it looks complex me , want retrieve following elements:
movelimitobjective": { "movelimit": 19, "jsonversion": 1
"gemspawnchance": { "r": 20, "b": 20, "g": 0, "p": 20, "y": 20 }
the 'board' block 'tiles' , 'pieces' blocks
"jellyobjective": { "jellytoremove": 16, "jsonversion": 1 }
i've seen plenty of examples on web, can't figure out. don't know begin.
thank in advance kind of help
use json2csharp convert json data csharp classes , convert resulting code vb.net using another converter.
once have classes in vb.net model data you're trying json, can use json.net's deserialize object method , grab properties want. example:
assuming you've set .net classes model json objects. i'll call top-level object game
.
dim json string dim game game = jsonconvert.deserializeobject(of game)(json) messagebox.show(game.gemspawnchance)
something close should work.
this example provides direction, doing more research helpful. maybe start newtonsoft.json page.
Comments
Post a Comment