Closed mhosman closed 1 year ago
Hi, thanks for reporting this issue. It sounds like a bug
I added a test case for this, but it is working as expected. Are you having JsonSerializerOptions.PropertyNameCaseInsensitive
value as false
it is the default if not set: https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions.propertynamecaseinsensitive?view=net-7.0 ?
In your provided sample the value in path
is writted in lower case. If you are using camel case property naming it should be myList
instead of mylist
?
Can you provide the actual JSON payload and actual models please?
Nevermind, is working fine. I just forgot to remove Newtonsoft from controller actions. Thanks guys! Great library!
If I'm trying to update an entire collection inside an object:
[ { "op": "replace", "path": "mylist", "value": [ { "languageId": "es", "name": "albert" } ] } ]
Model:
I get:
"Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'SystemTextJsonPatch.JsonPatchDocument`1[MyApi.Models.v1.MyModel]' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\nTo fix this error either change the JSON to a JSON object (e.g. {\"name\":\"value\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\nPath '', line 1, position 1."
This is working fine using Microsoft Json Patch.