need help with deserializing a json file

DiscordGoat

Member
Joined
Jan 30, 2022
Messages
8
Programming Experience
1-3
I am coding with my first API, and i got through most of the thinking and coding alright, but ive hit a snag with this part, and its really making me lose my cool. i keep getting a variation of Newtonsoft.Json.JsonReaderException: 'Unexpected character encountered while parsing value: {. Path 'data', line 1, position 22.'and occasionally it would just say "valmodel.data" meaning the ToString isnt working with the right data i think? any help is useful, feedback appreciated. learning fast is key. i can link the json if i need to as well [1]:
1643586409285.png
 
nevermind, this is what is in the Data_JSON
JSON:
{
    "status":200,
    "data":
    {
        "currenttier":9,
        "currenttierpatched":"Silver 1",
        "ranking_in_tier":78,
        "mmr_change_to_last_game":19,
        "elo":678,
        "name":"DiscordGoat",
        "tag":"6969"
    }
}
Did you know, you can copy the json and in VS use Edit > Paste Special > Paste Json as Classes
This will give you a Rootobject that you can deserialize. In this case it will have status and data properties, and a Data class. You may have to edit the generated classes, especially if you get different data for different requestes, but it will often be a good starting point.
 

Latest posts

Back
Top Bottom