Json merge
Exactjson_mergeDeterministic and authoritative — the canonical answer for this input.
Deep-merge two JSON objects (b wins on conflicts). Nested objects merge recursively; arrays and scalar values are replaced wholesale by b's value.
Parameters
astringrequiredThe base JSON object.
bstringrequiredThe overriding JSON object (wins on conflicts).
Call it
curl -X POST https://api.snipget.ai/v1/json/merge \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"a":"{\"theme\": {\"color\": \"blue\", \"size\": \"md\"}}","b":"{\"theme\": {\"color\": \"red\"}, \"lang\": \"en\"}"}'Example response
{
"is_valid": true,
"merged": {
"theme": {
"color": "red",
"size": "md"
},
"lang": "en"
}
}FAQ
What does deep-merge mean here?
It combines two JSON objects into one. Where both have the same nested object, it merges them recursively rather than throwing one away. So a base config plus an overrides config become a single complete config. The result is exact and repeatable.
Which side wins on a conflict?
The second object, b, wins. If both set the same key to a plain value, b's value is kept.
How are lists handled?
Arrays are replaced wholesale, not combined. If both objects have a list at the same key, b's list fully replaces a's. Only objects merge item by item.
Can I merge things that are not objects?
No. Both inputs must be JSON objects. If either is a list, number, or string at the top level, you get confidence 0 and a reason explaining it expects two objects.
What if one input is malformed?
You get a confidence 0 result naming the invalid JSON, not an error, so it is safe to call on user-supplied text.