swifty json - swiftyjson bundled file not parsing -
i've validated coding , works until actual parsing function unsure why not able of values in array of json file. have tried multiple methods of getting every object in array specified string , still nothing. example code have.
[ { "attack": 4, "card description": "<b>deathrattle</b>deal 2 damage other characters.", "card type": "0", "class": "10", "cost": 5, "health": 4, "name": "abomination", "rarity": 3 }, { "class": "1", "name": "fiery war axe", "cost": 2, "card type": 2, "card description": "", "rarity": 5 }, ]
if use:
json["array"].array
your json must like:
{ "array": [ { "attack": 4, "card description": "deathrattledeal 2 damage other characters.", "card type": "0", "class": "10", "cost": 5, "health": 4, "name": "abomination", "rarity": 3 }, { "class": "1", "name": "fiery war axe", "cost": 2, "card type": 2, "card description": "", "rarity": 5 } ] }
because "array" key array.
then can use: (json json array)
for obj in json["array"] { println(obj["name"].stringvalue) }
Comments
Post a Comment