# `JSON_MERGE_REPLACE` (function) > 如果2中的值1中存在,提供1胡 - **Type:** FUNCTION - **Returns:** `json` - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sJonsOne` | `json` | | 2 | IN | `sJsonTwo` | `json` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `JSON_MERGE_REPLACE`'`._ ## Narrative **Business context:** Polyfill for MySQL 8's `JSON_MERGE_PATCH` semantics on MySQL 5.7 — given two JSON objects, returns object 1 with object 2's keys overlaying it (each key from 2 *replaces* the same key from 1, instead of stacking into an array like the built-in `JSON_MERGE` does). Used by the dynamic-column-config layer that overlays per-user column-display tweaks on top of the system default config. **What it does:** validates both inputs are JSON. Iterates `JSON_KEYS(sJsonTwo)`; for each key, extracts its value from `sJsonTwo`, removes the same key from `sJonsOne` if present, then `JSON_MERGE`s the single-key object back in. Returns the rebuilt object. Loop body strips surrounding quotes from the extracted value unless it contains `{` (preserves nested objects). **Invocation:** referenced by `Fun_get_show_config_basic` — the baseline column-config resolver in the dynamic-report-column family (`Fun_get_show_config*`). Also surfaced in xly-src `script/标版/upgrade/动态配置返回函数/`. Header comment `如果2中的值1中存在,提供1胡` is truncated/garbled — function actually does the opposite (keys from 2 win over keys from 1).