C
C#17mo ago
BlackNet

✅ Problems with deserializing json

Hey guys, i am trying to deserialize a json response from server into class, but to no avail.
15 Replies
Jimmacle
Jimmacle17mo ago
what if you remove the JsonConstructorAttribute (and the empty constructor too)? that's not necessary
BlackNet
BlackNetOP17mo ago
same thing i started there, adding ctor and then [JsonConstructor] was just me trying stuff to make it work
TheRanger
TheRanger17mo ago
try deleting the required keyword
BlackNet
BlackNetOP17mo ago
tried that as well
TheRanger
TheRanger17mo ago
weird, let me try
BlackNet
BlackNetOP17mo ago
also used this to generate the classes from the json response https://json2csharp.com/
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.
BlackNet
BlackNetOP17mo ago
no
TheRanger
TheRanger17mo ago
works fine here did you recompile your project?
BlackNet
BlackNetOP17mo ago
i did
TheRanger
TheRanger17mo ago
you sure you are pointing to the correct Root class?
BlackNet
BlackNetOP17mo ago
yes oh fuck, i guess i found out the reason it's an AOT console application i will have to use the System.Text.Json source generator
TheRanger
TheRanger17mo ago
attack on titan?
BlackNet
BlackNetOP17mo ago
ahead of time compilation xD ¯\_(ツ)_/¯ when i compiled it not as an aot it works what's wierd is that it worked locally but when compiled for linux it didn't
Pobiega
Pobiega17mo ago
Reflection doesn't work on AOT. That's why you need sourcegen Yeah, same until I ran into it 🙂
Accord
Accord17mo 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