Apply a JSON Merge Patch to a Seller Product Listing
Last updated: November 29, 2026
Quick Overview
Implement PATCH for a product listing using JSON Merge Patch semantics: nested objects merge, null deletes a field, and arrays are replaced wholesale. Reject changes to immutable fields and invalid prices.
Amazon
November 29, 20260
0
0 solved
Implement PATCH for a product listing using JSON Merge Patch semantics: nested objects merge, null deletes a field, and arrays are replaced wholesale. Reject changes to immutable fields and invalid prices.
Listing updates from sellers are usually partial, and getting partial-update semantics wrong either drops attributes or makes deletion impossible. The interviewer checks recursion, the precise null and array rules, and validating the merged result rather than the patch alone.
What the Interviewer Expects
- Implements recursive merge for objects
- Treats null as delete
- Replaces arrays and scalars rather than merging them
- Does not mutate the stored listing
- Validates immutables in the patch and invariants on the merged result
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you express removing one element from the bullets array?
- When would you choose JSON Patch (RFC 6902) instead?
- How would you combine this with If-Match so concurrent patches are safe?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
PATCH /listings/{id}withContent-Type: application/merge-patch+json.{"attrs": {"size": null}}removes onlyattrs.size.asinandseller_idcannot change;price_centsmust remain a...
High-Level Design
merge_patch follows RFC 7386: if the patch is not an object it replaces the target; otherwise start from a copy of the target (or an empty object if the target is not one), delete keys whose value i...