C
C#3y ago
scixing

e different names during Serialize and Deserialize [Answered]

Is there a way to use Text.json to make members use different names during Serialize and Deserialize?
11 Replies
ero
ero3y ago
[JsonPropertyName("other-name")]
scixing
scixingOP3y ago
i mean Serialize use "AA" and Deserialize use "BB" I haven't found a good way to do this for the time angryowo
Cisien
Cisien3y ago
Custom converters And probably custom attributes
scixing
scixingOP3y ago
use JsonConverter?
Cisien
Cisien3y ago
A custom implementation, yes You basically have to write your own serialization or deserialization logic
scixing
scixingOP3y ago
thx, i will thxowo
Mayor McCheese
Just curious about your use case for this.
Cisien
Cisien3y ago
Im guessing some kind of translation between apis Or back compat?
Mayor McCheese
That's what I'm guessing in that scenario I'd push for different models tbh
scixing
scixingOP3y ago
hungrymeowo it look ok
Accord
Accord3y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server