We have our own Web API controllers and am finding that the deserialisation of models is using Newtonsoft (because of Umbraco I believe) and not System.Text.JSON is there a way for force it?
I’ve tried a custom model binder but this didn’t seem to work.
using Newtonsoft.Json;
using System.Text.Json.Serialization;
namespace Web.Global.Core.Models.Broker.Requests
{
public class OrderStatusRequest
{
[JsonPropertyName("csiOrderId")]
public string CsiOrderId { get; set; }
// we have to add this line and add Newtonsoft.Json to get the model binding to work, which we don't want to do
[JsonProperty("ecomOrderNumber")]
// this line JsonPropertyName is ignored from System.Text.Json, and the OrderNumber property is null
[JsonPropertyName("ecomOrderNumber")]
public string OrderNumber { get; set; }
[JsonPropertyName("status")]
public int OrderStatus { get; set; }
[JsonPropertyName("orderLines")]
public List<OrderStatusRequestOrderLine> OrderLines { get; set; }
}
}