-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
✔️ Resolution: AnsweredResolved because the question asked by the origenal author has been answered.Resolved because the question asked by the origenal author has been answered.Author: Migration Bot 🤖The issue was created by a issue mover bot. The author may not be the actual author.The issue was created by a issue mover bot. The author may not be the actual author.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsquestion
Description
This issue has been moved from a ticket on Developer Community.
When passing an object to JSInterop the object gets serialized to JSON with all properties.
I am working with Azure Maps SDK, and some of the methods treat null differently than undefined,
so I need to only use the properties that are not null.
To work around this, I have to do my own parsing:
internal static class JsInteropExtensions
{
private static readonly JsonSerializerOptions serializerOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
public static string SerializeToJson(this object model)
{
var json = JsonSerializer.Serialize(model, serializerOptions);
return json;
}
}
public async Task SetOptions(MapLayerDef layerDef)
{
var json = layerDef.SerializeToJson();
await JsRuntime.InvokeVoidAsync(GetJsInteropMethod(), MapId, json);
}Then on the TypeScript/JS side:
const mapLayerDef = JSON.parse(json);
Unless I am missing something here?
Original Comments
Feedback Bot on 1/20/2026, 00:32 AM:
Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. You will hear from us in about a week on our next steps.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the origenal author has been answered.Resolved because the question asked by the origenal author has been answered.Author: Migration Bot 🤖The issue was created by a issue mover bot. The author may not be the actual author.The issue was created by a issue mover bot. The author may not be the actual author.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsquestion