C
C#•3y ago
Metalkon

What am I doing wrong with this deserialized data?

When I run my program i'm only getting nulls and zero's when trying to access card prices from the json provided. Anyone have an idea on what I did wrong in my code? Json Used https://db.ygoprodeck.com/api/v7/cardinfo.php?name=Tornado%Dragon (reposted my question with less clutter)
5 Replies
TheRanger
TheRanger•3y ago
well cardmarket_price isnt on the root of the json, if you deserialized right, you access it like this
price.data[0].card_prices[0].cardmarket_price
price.data[0].card_prices[0].cardmarket_price
TheRanger
TheRanger•3y ago
you can let a site like https://json2csharp.com/ generate classes out of the json for you
Convert JSON to C# Classes Online - Json2CSharp Toolkit
Convert any JSON object to C# classes online. Json2CSharp is a free toolkit that will help you generate C# classes on the fly.
Metalkon
MetalkonOP•3y ago
That worked, had no clue it had to be typed down that way (or why [0] is needed).
TheRanger
TheRanger•3y ago
because data and card_prices are arrays
Metalkon
MetalkonOP•3y ago
i see i see thanks, now to see if i can find more information about this. 🙂
Want results from more Discord servers?
Add your server