Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
I will file a bug to Commerce team. Thanks for bringing this into our attention and apologies for the inconvenience.
There is a bug in ServiceApi when using System.Text.Json as default serializer with camelCase as formatting. Using Newtonsoft works as expected.
After some digging I the cause. JsonSerializerOptions in method GetSerializerOptions is not instanciated correctly while using camelCase. It is using the default constructor which will use PascalCase as default.
The options should set camelCase as PropertyNamingPolicy or use another constructor that takes default values.
private static object GetOptions() { if (ServiceProviderExtensions.TryGetExistingInstance<IActionResultExecutor<JsonResult>>(ServiceLocator.Current, out var instance) && instance.GetType().FullName.Contains("Newtonsoft")) { if (ServiceProviderExtensions.GetInstance<ServiceApiOptions>(ServiceLocator.Current).JsonPropertyNaming.Value == JsonPropertyNaming.PascalCase) { return new JsonSerializerSettings(); } return new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() } }; } return GetSerializerOptions(); } private static JsonSerializerOptions GetSerializerOptions() { JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions(); if (ServiceProviderExtensions.GetInstance<ServiceApiOptions>(ServiceLocator.Current).JsonPropertyNaming.Value == JsonPropertyNaming.PascalCase) { jsonSerializerOptions.PropertyNamingPolicy = null; } return jsonSerializerOptions; }