# `Fun_iCalcListJson` (function)

> 根据 JSON字符串LIST类型解析函数


- **Type:** FUNCTION
- **Returns:** `decimal(18,6)`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `p_json` | `longtext` |
| 2 | IN | `cloumnName` | `varchar(255)` |

## Body

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

## Narrative

**Business context:** JSON-array sum-reducer — given a JSON array `p_json` and a column name `cloumnName` (sic), sums the values of that column across all array entries and returns the result as `decimal(18,6)`. Used inside work-order data-pack std-calc routines to roll up nested per-part quantities pre-assembled in JSON form.

**What it does:** validates the JSON; walks `JSON_LENGTH` entries; for each entry `JSON_EXTRACT`s `$[i].<cloumnName>`, strips surrounding quotes, casts to `DECIMAL(18,6)`, adds to a running sum. Returns `0` on empty/invalid input.

**Invocation:** referenced by `Sp_WorkOrder_CalcDataBsProductStd` and `Sp_WorkOrder_CalcDataPackProductStd` (work-order base/pack product std-calc). xly-src copies also live under customer overlays (`script/客户/快马/`, `千彩/`, `金宣发/`).
