C
C#2y 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
ero2y ago
[JsonPropertyName("other-name")]
scixing
scixing2y 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
Cisien2y ago
Custom converters And probably custom attributes
scixing
scixing2y ago
use JsonConverter?
Cisien
Cisien2y ago
A custom implementation, yes You basically have to write your own serialization or deserialization logic
scixing
scixing2y ago
thx, i will thxowo
Mayor McCheese
Just curious about your use case for this.
Cisien
Cisien2y 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
scixing2y ago
hungrymeowo it look ok
Accord
Accord2y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server