You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have following class in my .net core 3.1 application
public class FinalsuccessResultForTransactionBase
{
[JsonPropertyName("auth_req_id")]
public string AuthReqId { get; set; }
[JsonPropertyName("correlation_id")]
public string CorrelationId { get; set; }
[JsonPropertyName("expires_in")]
public int ExpiresIn { get; set; }
}
public class FInalsuccessResultForPolling : FinalsuccessResultForTransactionBase
{
[JsonPropertyName("interval")]
public int Interval { get; set; }
}
when serializing i am getting it like
{"interval":10,"auth_req_id":"LoXBka93EiBcCvbwppHA","correlation_id":null,"expires_in":1800}
... Is there a particular reason you want it ordered? JSON is explicitly unordered.
It looks like this function isn't yet implemented, this is essentially a duplicate of issue #728. The recommendation there is to create a custom serializer.
... Is there a particular reason you want it ordered? JSON is explicitly unordered.
It looks like this function isn't yet implemented, this is essentially a duplicate of issue #728. The recommendation there is to create a custom serializer.
There is no big reason for ordering. In my logs i want's certain elements to come first. But it is very strange that basic order feature like newtonsoft is not there
But it is very strange that basic order feature like newtonsoft is not there
Because:
JSON is explicitly unordered.
System.Text.Json is a low-level base library for dealing with JSON. While it's possible to use it to de/serialize JSON with it, it was written in such a way as to be extensible by other libraries, who might do things like provide ordering.
If you want the items to be ordered to make your logs more readable, I'd actually recommend looking for a tool like Splunk, which can pull such data out, be able to search on it, etc.
I have following class in my .net core 3.1 application
public class FinalsuccessResultForTransactionBase
{
[JsonPropertyName("auth_req_id")]
public string AuthReqId { get; set; }
when serializing i am getting it like
{"interval":10,"auth_req_id":"LoXBka93EiBcCvbwppHA","correlation_id":null,"expires_in":1800}
I wanted it like
{"auth_req_id":"LoXBka93EiBcCvbwppHA","correlation_id":null,"expires_in":1800,"interval":10}
What should i do
The text was updated successfully, but these errors were encountered: