I want to be able to patch an item that consist of multiple properties, some of them are collections of classes. For now, I do not have any collection in the child classes, but potentially they can be added later.
For deleting an item with json patch, RFC 6902 specifies you need to call "remove" on the array index. However, this is unpractical to use, as if collection changes in the storage, the id for the item you want to delete might change.
Is there a way to practically identify an item inside a collection? I understand, if you want identify an item by value and allow duplicates, that can go differently to what you want, but in my case I have collections of classes with a unique id to be present.
Maybe, there are some .net core libraries that allow non-standard approach, for example,
[
{ "op": "remove", "path": "/foo/id/357" }
]
to remove item that is a class with id property equal 357.
Editing is a similar problem, especially, if one needs to PATCH the child item partially, not just delete the item and insert the modified one.
Edit:
There is a request for a value-based array operations. I don't think it is suitable as it will only cover simple types and ignore complex types. It also ignore duplicates. Plus, it was created in 2017 and has not been fullfiled in mid-2022 yet.
There is a similar query with an answer saying it is not possible by the standard answered on 2014.
However, I am also interested in a non-standard approach as the only alternative I see currently would be to write a separate PUT/DELETE methods for every collection property and keep adding them when new collection property is added.
What I had to do was to write separate POST/PUT/DELETE for all such children which is not ideal at all, but I could not rely on standard PATCH in that scenario.