C
C#2y ago
maria 🌟

❔ Null exception

22 Replies
maria 🌟
maria 🌟2y ago
I know thath some times thath will be null but i dont want an exception to ocurres
Thinker
Thinker2y ago
What are you doing? What are you deserializing?
maria 🌟
maria 🌟2y ago
response of server
Thinker
Thinker2y ago
Deserialize the response to a class Do not use dynamic
maria 🌟
maria 🌟2y ago
i prefere JsonNode :c
Thinker
Thinker2y ago
Do NOT use dynamic
maria 🌟
maria 🌟2y ago
why 😰
Thinker
Thinker2y ago
Because dynamic disables all type safety. This means you won't get any intellisense, any type hints, any compile-time safety, etc.
maria 🌟
maria 🌟2y ago
Tell me why Ain't nothin' but a heartache
Thinker
Thinker2y ago
Dynamic is capital B Bad in 99.999% of cases It should not be used unless there is a very very very good reason This is not one of them
maria 🌟
maria 🌟2y ago
i dont know the whole response of the server :/
Thinker
Thinker2y ago
What server is it?
maria 🌟
maria 🌟2y ago
im scraping the api of my router to make an watcher of the cpu and ram of my router on real time
Thinker
Thinker2y ago
of your router...?
maria 🌟
maria 🌟2y ago
and then make analitycs yea 😃 modem but i guess i will just ad and try catch :C
Thinker
Thinker2y ago
Well, you should still be deserializing to a class for the information you do know
maria 🌟
maria 🌟2y ago
yes but
Thinker
Thinker2y ago
Paste your JSON into $jsongen
MODiX
MODiX2y ago
Use https://app.quicktype.io or https://json2csharp.com to generate classes from your JSON
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.
maria 🌟
maria 🌟2y ago
but some times changes idk my router is kinda sus
Thinker
Thinker2y ago
These automatically generate classes from your JSON that definitely seems sus
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server