JSON Deep Merge
A JSON deep merge recursively combines two or more JSON objects, merging nested objects key by key rather than replacing them wholesale. When keys conflict, a defined rule decides which source wins, producing one unified object from multiple API responses.
Technical Architecture & Deep-Dive
A shallow merge like `Object.assign` replaces nested objects entirely, so merging two profiles with different `settings` objects loses one of them. A deep merge walks the structure and combines nested values.
When aggregating APIs, such as an auth provider profile and a database profile, deep merges need explicit conflict rules. Declarative output mappings are often clearer, because each target field names its exact source.
Key Architectural Benefits
Implement JSON Deep Merge at the Edge
Deploy lightweight API aggregation, edge caching, and secret injection in minutes without Docker containers or complex servers.
Frequently Asked Questions
Q:How are arrays handled in a deep merge?
Strategies vary: replace the array, concatenate both, or merge items by a key such as id. Choose explicitly to avoid surprises.
Related Architecture Concepts
API Aggregation is the process of combining multiple distinct API calls into a single unified HTTP request. An intermediate edge gateway queries multiple upstream services in parallel, merges the returned data, and delivers a consolidated response to the client, drastically reducing mobile latency and network overhead.
Response mapping is defining how fields from one or more upstream API responses are selected, renamed, and placed into a new output structure. Each mapping rule connects a source path, such as customer.email from a billing step, to a target path in the client response.
Data denormalization is combining related data into a single record or response, even if it duplicates information, to make reads faster and simpler. Instead of clients joining users, plans, and invoices themselves, a denormalized response embeds everything needed in one object.
Ready-to-Use Edge Recipes
To combine firebase auth user with supabase profile endpoint, use one RealComposer pipeline with parallel steps. Firebase ID token lookup and Supabase profile row merged at edge. Your React / Flutter / Mobile app makes one request instead of several sequential upstream calls.
You do not need to spin up an Express, FastAPI, or Docker microservice just to stitch REST APIs together. RealComposer fetches multiple upstream endpoints concurrently at the edge, injects private credentials, and combines the responses into a single JSON schema with sub-10ms response times.