// this class (like all the others) are of course much more complicated than this. // There's also a lot of abstraction etc (you can see the actual code on the github I've linked at the start). SomeConfig config = new SomeConfig { Options = new SomeOptions { SomeInt = 2, SomeString = null, // any trace of this property will not be present in the expando object Axes = new List<Axis> { new Axis() // this axis will also be an expandoObject after being extracted from the json } }, Data = new SomeData { Data = new List<int> { 1, 2, 3, 4, 5 }, SomeString = "asdf" } }; dynamic expando = /* ParseConfigToJsonWithoutNulls -> ParseJsonToExpandoObject */ IJSRuntime jsRT = GetTheRuntime(); jsRT.InvokeAsync("blabla", expando); // this would NOT work because ExpandoObject cannot be serialized to json correctly and throws a runtime error // this method is what we need in the best way possible without missing something :) Dictionary<string, object> dictFromExpando = ConvertExpandoToDictonary(expando); // so the only purpose of the ConvertExpandoToDictonary is to recursively convert all the ExpandoObjects to Dictionaries as they are serializable // I have to do this recursively since there are nested ExpandoObjects that were created when parsing the huge json to the ExpandoObject with Json.Net // I have decided to go with Dictionaries because it works and ExpandoObject implements the interface IDictionary<string, object> jsRT.InvokeAsync("blabla", dictFromExpando); // this now works perfectly fine I have asked a new, much more detailed question. Please have a look at it if you have the time :)
Also I have no problem with people copying their answers 1:1 if they are still accurate.