✅ JSON names collide? Avalonia
Between the model class and the function I'm using it in, I have something wrong. I get the error
The JSON property name for 'Diary.Models.UserSetting.default' collieds with another property.
This is a new error to me. I tried looking at https://stackoverflow.com/questions/69448540/net-core-the-json-property-name-for-collides-with-another-property and https://stackoverflow.com/questions/24887705/json-net-conflicting-property-name-when-using-jsonpropertyattribute but I can't determine what I have wrong. Thanks.57 Replies
should I remove the
[JsonPropertyName("default")]
from the class decorators?well, it's saying you have 2 property names that conflict and you're giving 2 properties identical names
I wasn't sure if they both needed the decorator
the attribute is for specifying a non-conventional name, it's not required at all
attribute. not decorator that's what I meant lol
if it's not present the serializer will name the property based on the CLR property name and whatever naming convention you set in the options
ok well the function is supposed to create a json file that looks like this
so that as the user changes their custom settings, it can be added to replaced or deleted.
i don't see any properties named "default" there
"default"
would be present if the file is just newly created in place of "Username here"
. In the function parameters, string username = "default"
is therethe attributes name the properties they're put on, not the parent
it'll also remain there too as it's the style for the loading screen and the login screen
ok so how should I fix my current code to get my desired output?
remove the attributes
you're currently trying to name the "styles" and "settings" keys to both be "default" instead, which would produce invalid json
ok they're removed.
is there anything else I should change?
did that fix your problem?
it did, however, it's a dictionary within a list instead of just a dictionary
wait
I guess that's ok