✅ Problems with deserializing json
Hey guys, i am trying to deserialize a json response from server into class, but to no avail.
15 Replies
what if you remove the JsonConstructorAttribute (and the empty constructor too)? that's not necessary
same thing
i started there, adding ctor and then [JsonConstructor] was just me trying stuff to make it work
try deleting the
required
keywordtried that as well
weird, let me try
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.
no
works fine here
did you recompile your project?
i did
you sure you are pointing to the correct
Root
class?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
attack on titan?
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
Reflection doesn't work on AOT. That's why you need sourcegen
Yeah, same until I ran into it 🙂
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.