21

It would be great and interesting to try out suppressing null and default values when serializing ODATA/JSON payloads. It would be interesting to see if if can shave off payload and a few milliseconds in network connectivity.



Can you please try out the effect of this ? For situations with limited network bandwidth it could have a very positive effect :-)



Here is a small C# samplecode on how to reduce the JSON payload.




using System.Runtime.Serialization;

using System.Text.Json;

using System.Text.Json.Serialization;



[DataContract]

public class TestClass

{

    [DataMember]


    public bool B1 { getset; }



    [DataMember]

    public bool B2 { getset; }



    [DataMember]

    public string? S3 { getset; }

}



class Program

{

    static void Main()

    {

        TestClass tc = new() {B1 = true};

        JsonSerializerOptions options = new JsonSerializerOptions();

        options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault;

        var serialized = JsonSerializer.Serialize(tc, options);



        Console.WriteLine(serialized);

   }

}




Prints: {"B1":true}




Category: Performance
STATUS DETAILS
Completed
Ideas Administrator

Thank you for the suggestion and interest in making the product better. We've completed the implementation of this idea. It is enabled by default starting with the 10.0.31 release. This feature reduces the network payload by omitting any properties that have a default value.

In our internal testing, we've seen savings of approximately 20% in data payload size, though actual savings will vary by specific APIs and data composition, and savings can range anywhere from 5% to 50%. This is particularly helpful in mobile or low bandwidth scenarios.