C#C
C#3y ago
Kyede

❔ Creating a json array and reading a specific property

Hello!

So i have a json file as followed
{
    "embeds": [
        {
            "embed1": {
                "title": "test number 1",
                "description": "test",
                "type": "rich",
                "color": 79376
            },
            "embed2": {
                "title": "test number 2",
                "description": "test",
                "type": "rich",
                "color": 79376
            },
            "embed3": {
                "title": "test number 3",
                "description": "test",
                "type": "rich",
                "color": 79376
            }
        }
    ]
}


I want to read let's say everything from embed1 as if it was its own file. The thing to consider is that it has to be a string since the parameter is a string since im reading it like this

var parseObj = (JObject)JsonConvert.DeserializeObject($"App/Data/Configuration/embed.json");

EmbedBuilderUtils.TryParse(parseObj.SelectToken("embeds[0].embed1").ToObject<string>(), out var builder);


I am getting this error and idk what to do... Unexpected character encountered while parsing value: A. Path '', line 0, position 0..
Was this page helpful?