15 Replies
Deserialize into a class.
You can use https://json2csharp.com/ that makes it easier to convert json into a C# class.
Deserialize -> json (string) to object
Serialize -> object to json (string)
thanks guys i got it right finally
Why is there two people in the server, right now, trying to deserialize JSON to
dynamic
Another thing to add to my Solution1 talk I guess lol
lol i cant build such huge object, that what i really dont need. appretate your help though ❤️
$jsongen
Instantly parse JSON in any language | quicktype
Whether you're using C#, Swift, TypeScript, Go, C++ or other languages, quicktype generates models and helper code for quickly and safely reading JSON in your apps. Customize online with advanced options, or download a command-line tool.
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.
Try avoiding dynamic. Go with concrete objects.
Dictionary<string, object>
is only slightly less worse
Also, your code seems to be using WebClient
?You are total right, as I said a concrete object is much better. But I got lazy there. I'm not sure what you mean by WebClient?
No it's using HttpClient! if that's what you mean.
Ah, my mistake then
Seemed too complex for a httpclient, since you can just use
await client.GetAsJsonAsync<MyClass>(url);
Oh maybe I overcomplicated it. I wasn't aware you could do
await client.GetAsJsonAsync<MyClass>(url);
yeah that for sure simplifies it. Good to know.Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.