# `FUN_DISTINCTJSON_REMOVE_BYNAME` (function)


- **Type:** FUNCTION
- **Returns:** `longtext`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sJson` | `longtext` |
| 2 | IN | `sName` | `varchar(100)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `FUN_DISTINCTJSON_REMOVE_BYNAME`'`._

## Narrative

**Business context:** Generic JSON-array dedup helper — given a JSON array of objects and the name of one key, returns a new JSON array with rows whose value at that key has already been seen filtered out. Sits with the rest of the JSON-utility family used to clean up dropdown / pick-list data assembled inside form-master sSqlStr blocks.

**What it does:** validates `sJson`, iterates `0..JSON_LENGTH-1`, extracts each element's `$.<sName>`, keeps a running comma-joined seen-list, and `JSON_MERGE`s only first-occurrence elements onto the output array. Returns a JSON array; invalid JSON falls through to an empty array.

**Invocation:** Status: appears orphaned. No caller found in any channel (form-master sSqlStr, gdsmodule hooks, other routines, exhaustive xly-src grep, dynamic-dispatch search) — candidate for maintainer audit.
