Serialization and Deserialization Issues

Ive been trying to get serialization to work for my C# World object, but I'm recieving this error, quite often, but with different lines of course. An example of the error, the JSON it was trying to read, a specific excerpt of it, and more are provided below. System.Text.Json.JsonException: 'The JSON value could not be converted to System.Collections.Generic.List`1[Lightrealm.District]. Path: $.WorldMap[3766].MyLocation.DistrictsToAdd | LineNumber: 33915 | BytePositionInLine: 27.' I have some more infomration on my code in the attached text file, including an excerpt of the JSON. I've also attached the entire JSON file, but it is rather massive. According to some of my research the file structure might not be parseable into a list? No information on how to fix that, or why the program would store it in a different way than it reads. I thought it would, in theory, serialize from the list and then deserialize it back into a list? If anyone has run into issues like this with deserialization, or knows what I'm doing wrong, I would appreciate the help. I can provide more information if need be. Thank you!
2 Replies
Angius
Angius12mo ago
Well, if it really is this that throws the error
"DistrictsToAdd": {
"$id": "3771",
"$values": []
},
"DistrictsToAdd": {
"$id": "3771",
"$values": []
},
then no wonder, this isn't a list DictrictsToAdd.$values is An empty one
fiefensneifiefens
fiefensneifiefensOP12mo ago
does that just mean it was null when it was serialized? I thought it accounted for that the data is directly from a c# object with no afterward modification so im not sure what the initial value was that caused it to be empty
Want results from more Discord servers?
Add your server