I have a basic ASP.NET Web API project. When I send a request, the serialization is done using System.Text.Json. However, when I send a non-valid json, for example text instead of number, it returns a binding validation error:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"model": [
"The model field is required."
],
"$.items[0].price": [
"The JSON value could not be converted to System.String. Path: $.items[0].price | LineNumber: 4 | BytePositionInLine: 24."
]
}
}
I'm having a bit of a problem with the name of the property $.items[0].price. It bothers me the character - $. I tried to search if there is any way to make my PropertyNameSolver, but I didn't find anything. I know that you can do a replace in the property name, but I really don't like that...
Is there maybe some elegant way to change the property name and its wording?
Thanks
$just stands for the root of the JSON .....$.items[0].pricemeans: the firstitemselement in the root, and then itspricefield