Bug: custom serializer settings are ignored
See original GitHub issueWhen setting custom serialization settings on JsonApiOptions
, they are not used. In our scenario we have a few enums exposed as attributes and we want them to serialize into their text representation instead of numeric.
Example:
public enum ScreenOrientation
{
Horizontal, Vertical
}
public class DemoResource : Identifyable
{
[Attr]
public ScreenOrientation Orientation { get; set; }
}
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddJsonApi<AppDbContext>(options =>
{
options.SerializerSettings.Converters = new List<JsonConverter>
{
new StringEnumConverter()
};
});
}
}
Putting [JsonConverter(typeof(StringEnumConverter))]
on ScreenOrientation works, but the global setting does not.
Using the global setting should work, according to https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/docs/usage/options.md#custom-serializer-settings.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
IJSRuntime ignores custom json serializer in server side ...
I first serialized my object with json.net so I could define NullValueHandling = NullValueHandling.Ignore and so all the custom converters ...
Read more >How to ignore properties with System.Text.Json
To ignore individual properties, use the [JsonIgnore] attribute. The following example shows a type to serialize. It also shows the JSON ...
Read more >The Serializer Component (Symfony Docs)
All attributes are included by default when serializing objects. There are two options to ignore some of those attributes. Option 1: Using @Ignore...
Read more >Bug: Files opened in append mode should not be used ...
Members ignored during record serialization should not be used. Bug ... AssertJ methods setting the assertion context should come before an assertion. Bug ......
Read more >Json ignore property javascript. Use the unsafe encoder only
Overview This tutorial will show how to ignore certain fields when serializing an object to JSON using Jackson 2. Jackson provides an ObjectMapper...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Update: After discussion, we decided to keep the Newtonsoft.Json setting and remove
ISerializerOptions
.To clarify: The work that needs to be done here, in additional to the changes in #688, is to remove the
JsonApiDotNetCore.Configuration.ISerializerOptions
interface and update its usages to useNewtonsoft.Json.JsonSerializerSettings
instead.