Open lambdageek opened 2 years ago
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis See info in area-owners.md if you want to be subscribed.
Author: | lambdageek |
---|---|
Assignees: | - |
Labels: | `area-System.Text.Json` |
Milestone: | - |
/cc @pavelsavara
Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.
Author: | lambdageek |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `arch-wasm`, `area-System.Runtime.InteropServices.JavaScript` |
Milestone: | Future |
Why not use STJ? Maybe I don't understand the use case.
Not sure how this will work with <RunAOTCompilation>true</RunAOTCompilation>
. Currently, to make AOT work, I have to create a JsonSerializerContext
. Otherwise, the following warning appears:
Using member System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)
which has RequiresUnreferencedCodeAttribute
can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo
or JsonSerializerContext
, or make sure all of the required types are preserved.
Yes, we already have json trimming issue on Blazor https://github.com/dotnet/aspnetcore/issues/39839
Since we have code generator here, we could generate
[JsonSerializable(typeof(List<Item>))]
private partial class ItemListSerializerContext : JsonSerializerContext { }
consider some code like this:
Right now to make use of something like that from JavaScript, we have to write some boilerplate:
It would be nice if we had a convenience marshaler for moving Json blobs around: