Sunday, February 25, 2018

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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...