Struggling with JSON
Any Idea why does this operation makes half of the fields = null without any errors or anything, just half of the fields in the class become null without any real pattern
25 Replies
really would need to see the class being serialized
and maybe the SerializerOptions
printing the string form of
a
might also give hints as to whether the problem starts at the serialization phase, rather than the deserialization phaseit serializes normally, I can send full json
one sec
here are options
custom converters just trying to things to work
this is json
and basically json looks fine to me, it totally copies all fields
just deserializer struggles
do you have an example of which properties end up null?
(assuming its always the same ones)
yeap one sec, I have pretty wild one
yes
basically you can see here the Buildings one, but if we look at the province data it has literally same buildings list but in that case they normally deserialized
but in provinces on the other hand there are other fields that got badly deserialized
I just don't have any idea why this can happen
crazy question, what if you make Buildings a list on CustomScenario
(noting, that should not matter, but thats a difference lmao)
it was before, the same
happens
i tried to change it to array and nothing changed
it did not work though until I wrote this converter
which literally does nothing new
does that mean it was always null before this converter, regardless of type?
wdym?
ohh, i see
it threw errors
)))
asking for the specifics of
it did not work though until I wrote this converterBecause I'm surprised this required custom
without it
hmm, curious what those are
nevermind it still works when I turned it off
idk why I wrote it then
probably was trying to make main property not null
this is ending up one of those "oh god what is System.Text.Json doing?" things lol
do you have a repo of this by chance?
i have but it's private I can send you rider code with me link or zip of .cs files if you want
never used code with me, but let's try it, sounds interesting
one sec
send in dm
if it was autoblocked
btw
For future readers, evidently
System.Text.Json
will not access the backing fields of auto properties via reflection (by default? for overridden props? ever?), so if there is no set;
-er, you're toast