Shortly, I’m trying to create some web-API-application and I’m parsing telegram data and I am faced up with a problem.
When I get all the JSON, I see that the program can’t parse it because some field(text) couldn’t resolve the object(code snip below). I’m thinking about creating a custom JSON converter(that’s annoying, so that’s the reason why I’m here), but maybe I just don’t know how to do it correctly.
Here are examples:
{
"text": "SOME VERY VERY VERY PRIVATE INFORMATION",
},
AND
{
"text": [
{
"type": "link",
"text": "SOME VERY VERY VERY PRIVATE LINK :D(probably, onlyfans)"
}
],
}
2
Answers
I usually use a JsonConstructor in this case. You don’t need to pass all properties into the constructor, you can pass only the properties that cause a problem.
I would use
system.text.json
More info hereand here
and use it like this