Tuesday, 29 March 2016

Reading from JSON File C#

Hey guys I have this json file (excerpt):

https://hastebin.com/uzifiteqol.json
I have created a discord bot which responds to commands and one of the commands is *card (card name)
This JSON file provides the stats of all the cards, but I want the user to access the lvl 9 stats based on the idname (card name he puts)
For example:
*card arrows
This should give the user the area damage of lvl 9 arrows that are shown in the json, but I am not sure how to access this stat. Heres what I have so far:



string jsonString = File.ReadAllText("/Users/me/Desktop/cardstatsfile.json");



This is where the json file location is on my computer (mac)
I am not sure how to go from there, I was thinking that I would need JToken.parse and parse through the file to look for the "idname" or the card specified by the user. Thanks in advance!



EDIT: Clarification: Because there are 75 cards, I want to obtain the values of elixircost, rarity, ect and also all the lvl 9 stats just by providing the idname. Or do I need to reformat the JSON to do this?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...