所以,我正在開展一個學校項目,我正在試圖找出處理這個包含相當大量的JSON對象的數據文件的最佳方法。我知道VB.net的基礎知識,基本的事件處理等。如何使用VB.net解析此JSON?
我知道設計結構的基礎知識,以及類似的東西,但我需要弄清楚如何解析和創建一個5MB的對象列表JSON文件,該文件包含的條目,如下列:
{
"Air Elemental":{
"layout":"normal",
"name":"Air Elemental",
"manaCost":"{3}{U}{U}",
"cmc":5,
"colors":[
"Blue"
],
"type":"Creature — Elemental",
"types":[
"Creature"
],
"subtypes":[
"Elemental"
],
"text":"Flying",
"power":"4",
"toughness":"4",
"imageName":"air elemental"
},
"Ancestral Recall":{
"layout":"normal",
"name":"Ancestral Recall",
"manaCost":"{U}",
"cmc":1,
"colors":[
"Blue"
],
"type":"Instant",
"types":[
"Instant"
],
"text":"Target player draws three cards.",
"imageName":"ancestral recall"
},
"Animate Artifact":{
"layout":"normal",
"name":"Animate Artifact",
"manaCost":"{3}{U}",
"cmc":4,
"colors":[
"Blue"
],
"type":"Enchantment — Aura",
"types":[
"Enchantment"
],
"subtypes":[
"Aura"
],
"text":"Enchant artifact\nAs long as enchanted artifact isn't a creature, it's an artifact creature with power and toughness each equal to its converted mana cost.",
"imageName":"animate artifact"
}
}
如果任何人都可以提供幫助,或者只是有點點我在正確的方向,我會很感激。我認爲這扔我送行的大多數部分是每張卡的名字本身就是一個鍵,所有卡上的數據是一個名爲「鍵」相關聯的值...
很酷,現在給它一個鏡頭。 – MisutoWolf
所以,我試着去說,從閱讀這個文件生成的卡片字典的長度,我試圖解析,它似乎並沒有工作。代碼在這裏:http://pastebin.com/5EWVKTVL – MisutoWolf
你不能一次反序列化一行。擺脫streamreader,只需使用'jstr = File.ReadAllText(datafile)' – Plutonix