Json serialization issue ?

  1. #1

    Json serialization issue ?

    is the Ext.Net serialize the object(s) by depending on the options specified at startup ?

    actually I tried 2 options shown below but result never changed :(

    .AddRazorPages().AddJsonOptions(options => {
         options.JsonSerializerOptions.IncludeFields = true;
         options.JsonSerializerOptions.DefaultIgnoreCondition = WhenWritingNull;
    .AddRazorPages().AddNewtonsoftJson(options => {
         options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
    I have a class named XYZ; and wanna return a List<XYZ> to the client on anciton -> OnPostBUTTON_CLICK

    public IActionResult OnPostBUTTON_CLICK()
         var data = new List<XYZ>() {
              new XYZ() {field1="val-11",  field2= "val-12" },
              new XYZ() {field1="val-21",  field2= "val-22" }
         this.X().Call("js-function", data);
         return this.Direct();
    private class XYZ{
         public string field1;
         public string field2;

    but at this point seems like Ext.Net does not render the field(s) in class by depending on MVC JsonOptins.

    please I'd be liked you to suggest me any idea/offer :)
  2. #2
    Hello @serkane!

    No, it uses its own serializer and whatever you set to ASP.NET / CLR Json won't interfere (and shouldn't) its behavior.

    EDIT: the FallbackToStreamRender has nothing to do with the serializer. Instead it is related to how Ext.NET injects code to the generated pages and is used in some scenarios i.e. when the page has no <head /> tag.

    Hope this helps!
    Last edited by fabricio.murta; Feb 03, 2021 at 1:21 AM.
  3. #3
    I have received some information here I also didn't know that might help you understand or resolve your issue.

    The this.Direct(result) override (when you pass a value to it) does use a regular JsonSerializer to serialize the result value. You get a result field from the response that you could use from a callback event.

    the this.X().Call("js-function", data); will use an ISerializationService instance to serialize the data value instead.

    Now I can't really go any further because the test code you provided doesn't seem to run without some dependencies. Switching the project to .NET 5 helps with the options.JsonSerializerOptions, but adding Newtonsoft.Json package doesn't add AddNewtonsoftJson() and I have no idea where the WhenWritingNull came from.

    If you still need help with this, please provide a code sample that can be run. Also tell us what you expected with either setting (you could add code to do the serialization the way you expected it to work -- maybe just writing it to a temp string var in code behind).

    So, for now we cannot tell it is an issue or not, we would need to be able to reproduce the scenario.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [OPEN] [#1841] Problem with JSON serialization in direct method
    By lbrohan in forum 5.x Legacy Premium Help
    Replies: 6
    Last Post: Nov 13, 2020, 4:25 PM
  2. JSON.Serialize issue
    By fragrance22 in forum 2.x Help
    Replies: 0
    Last Post: Jan 24, 2013, 5:40 AM
  3. JSON.Serialize issue
    By fragrance22 in forum 1.x Help
    Replies: 0
    Last Post: Jan 22, 2013, 12:58 PM
  4. [CLOSED] JSON Serialization to Spec
    By Z in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Dec 18, 2012, 7:44 AM
  5. [CLOSED] JSON deserialisation issue with multicombo boxes.
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 01, 2012, 10:54 AM

Posting Permissions