I have a JSON object of arbitrary complexity, representing several entities (not my design choice). I want to partially persist it, only for the changed entities. What would be the best way to mark the parts of it that I will update? (Think "dirty bit"). The JSON will be passed around several microservices (again, not my choice), and it will only be persisted to the DB at the very end.
- Generate a dirty flag for each subobject, which is tedious and error-prone.
- Keep a separate, sparse object that represents a "patch", and iterate this "patch".
- Keep a copy of the original, and change the pass-around object. Finally, run a diff of the two (slow) and persist the changed sub-entities.
Is there any other way that makes sense and I should consider?