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
Software Engineering Fundamentals
Software Engineer
Amazon
November 29, 2026
Software Engineer
Phone Screen
Software Engineering Fundamentals
Easy

0

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
JSON Merge Patch
partial updates
recursion
validation
immutability
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. 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 Problems
Sample Answer
Requirements
  • PATCH /listings/{id} with Content-Type: application/merge-patch+json.
  • {"attrs": {"size": null}} removes only attrs.size.
  • asin and seller_id cannot change; price_cents must 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...


Submit Your Answer
Markdown supported