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
More Posts
❔ How to write Process name into XML file ?I try to write my Process name into xml file like this: ```csharp foreach(var process in Process.Get[CSS-HTML] Page Layout, annoying random lines [Answered]Hello everyone, i made another page on a project im working on, but some random grey horizontal line❔ [SOLVED] Reducing the size of an executablehello there what are my options to reduce the size of an executable? Here's how I publish it ```sh d❔ [SOLVED] PublishAot and PublishSingleFile at thesame timeI have a very simple app and I want to reduce its size and have a good start up time. Here's my curr❔ ASP.NET Core Middleware running only onceHello! I have a custom middleware that runs only once and isn't running on every request. When I pu❔ ❔ Upgrading my function app to .NET 7 - Could not load file or assembly System.ComponentModelI've tried to upgrade my Azure Function App to .NET 7. But `Microsoft.Azure.WebJobs.Extension.Stora❔ How to set a time interval in a timer ?This is the class: ```csharp public string ProcessName { get; set; } public int MaximumLifeTime { ge❔ EntityFramework does not track changes for the select projectionHey, With Select (), I only extracted the data I needed, which I want to update later. However, afte❔ Using concurrent collections to add or remove elements for in-memory collections (server)?Should we use concurrent collections to add/remove elements to/from in-memory collections in asp.net❔ .NET 6 GET method returns OK even if there is no such endpointI've a .NET 6 Web Application with Blazor wasm front-end. When I make an HTTP GET request from fro