# Input Access

> 以条目形式呈现的同一输入：当前条目与条目列表。

Source: https://docs.sommatic.ai/zh/expressions/reference/input-access/

每个示例都在已部署的表达式引擎上、基于页面末尾的[示例上下文](#example-context)运行过。

## `$input.item`

属性 · `{ json, binary }` · 来源: `Sommatic AI expression engine`

```javascript
$input.item
```

以条目形式表示的当前节点输入：`json` 与 `$json` 是同一个对象，`binary` 即 `$binary`（始终为 `{}`）。适用于按其他工具的条目风格编写的表达式。

### 示例

```javascript
{{ $input.item.json.body.order_id }}
```

结果 (string):

```json
"ord_1042"
```

```javascript
{{ Object.keys($input.item) }}
```

结果 (list):

```json
[
  "json",
  "binary"
]
```

### 说明

- 在 `code.js` 节点中，`$input` 含义不同：它就是输入对象本身，没有 `{ json }` 包装。参见[代码节点](/zh/expressions/code-nodes/)。

在 JSONata 中: `$$input.item.json.body.order_id`

## `$input.all()`

函数 · `list` · 来源: `Sommatic AI expression engine`

```javascript
$input.all()
```

以 `{ json, binary }` 列表的形式返回输入条目。一个节点每次执行只处理一个条目，因此该列表始终恰好有一个元素：`$input.all()[0].json` 就是 `$json`。要处理数据中某个列表的元素，请直接使用该列表（`$json.body.items`）。

### 示例

```javascript
{{ $input.all().length }}
```

结果 (number):

```json
1
```

```javascript
{{ $input.all()[0].json.body.email }}
```

结果 (string):

```json
"ana.perez@example.com"
```

在 JSONata 中: JSONata 中无法调用函数；请改为读取 `$$input.item.json`。

## `$input.first()`

函数 · `{ json, binary }` · 来源: `Sommatic AI expression engine`

```javascript
$input.first()
```

返回第一个输入条目 `{ json, binary }`：由于只有一个条目，它就是当前条目。等同于 `$input.all()[0]` 和 `$input.item`。

### 示例

```javascript
{{ $input.first().json.body.customer.name }}
```

结果 (string):

```json
"Ana Pérez"
```

在 JSONata 中: JSONata 中无法调用函数；请改为读取 `$$input.item.json`。

## `$input.last()`

函数 · `{ json, binary }` · 来源: `Sommatic AI expression engine`

```javascript
$input.last()
```

返回最后一个输入条目 `{ json, binary }`：由于只有一个条目，它就是当前条目。

### 示例

```javascript
{{ $input.last().json.body.order_id }}
```

结果 (string):

```json
"ord_1042"
```

在 JSONata 中: JSONata 中无法调用函数；请改为读取 `$$input.item.json`。

## `$input.params`

属性 · `object` · 保留 · 来源: `Sommatic AI expression engine`

> **保留.** 引擎不会填充它：目前始终为 `{}`。

```javascript
$input.params
```

用于暴露产生该输入的节点的配置参数。引擎不会传递这些参数：它始终是空对象。要复用之前某个节点配置中的值，请让该节点在输出中返回它，或者再填写一遍。

### 示例

```javascript
{{ $input.params }}
```

结果 (object):

```json
{}
```

在 JSONata 中: `$$input.params`

## `$input.context`

属性 · `object` · 保留 · 来源: `Sommatic AI expression engine`

> **保留.** 引擎不会填充它：目前始终为 `{}`。

```javascript
$input.context
```

用于从产生该输入的节点携带上下文数据。引擎不会填充它：它始终是空对象。需要在节点之间传递的数据应放在节点的输出中，并用 `$json` 或 `$('…')` 读取。

### 示例

```javascript
{{ $input.context }}
```

结果 (object):

```json
{}
```

在 JSONata 中: `$$input.context`

## 示例上下文

示例基于以下数据运行：当前节点的输入（`$json`）、已运行的节点（`$(…)`）、本次运行的 ID 以及当前节点。时钟固定为 `2026-11-26T14:30:00.000Z`，服务器时区为 UTC，因此各页面中 `$now` 与 `$today` 的值都相同。

```json
{
  "$json": {
    "body": {
      "order_id": "ord_1042",
      "email": "ana.perez@example.com",
      "customer": {
        "name": "Ana Pérez",
        "segment": "gold"
      },
      "priority": "",
      "items": [
        {
          "sku": "A-100",
          "qty": 2,
          "price": 10.5
        },
        {
          "sku": "B-200",
          "qty": 0,
          "price": 4
        },
        {
          "sku": "C-300",
          "qty": 1,
          "price": 25
        }
      ],
      "tags": [
        "new",
        "web",
        "new"
      ],
      "created_at": "2026-11-25T09:15:00Z"
    },
    "headers": {
      "content-type": "application/json"
    },
    "query": {},
    "method": "POST"
  },
  "nodes": {
    "Webhook Receiver": "= $json",
    "Normalize input": {
      "correlation_id": "c-7f3a",
      "channel": "web"
    },
    "Classify": {
      "label": "billing",
      "confidence": 0.92
    }
  },
  "run": {
    "$flow_instance_result_id": "fir-xxxx",
    "$flow_instance_id": "fi-xxxx",
    "$flow_definition_id": "fd-xxxx",
    "$flow_version_id": "fv-xxxx",
    "$flow_slug": "order-intake"
  },
  "node": {
    "node_id": "node-notify",
    "label": "Notify customer"
  }
}
```

串联工作流的示例基于第二个上下文运行：一个由 `workflow.chain` 启动的工作流，其 `workflow.trigger` 节点的标签为 `Chain Entry Point`。

```json
{
  "$json": {
    "order_id": "ord_1042",
    "customer_email": "ana.perez@example.com",
    "amount": 46,
    "chain_context": {
      "caller_flow_definition_id": "fd-caller-xxxx",
      "caller_flow_instance_id": "fi-caller-xxxx",
      "caller_flow_slug": "order-intake",
      "caller_node_id": "node-chain-billing",
      "correlation_id": "chain-7Hq2Lw9sKd3pXa1mZr4t",
      "root_flow_instance_result_id": "fir-root-xxxx"
    }
  },
  "run": {
    "$flow_instance_result_id": "fir-hop-xxxx",
    "$flow_instance_id": "fi-hop-xxxx",
    "$flow_definition_id": "fd-billing-xxxx",
    "$flow_version_id": "fv-billing-xxxx",
    "$flow_slug": "billing-review",
    "$input": {
      "data": {
        "order_id": "ord_1042",
        "customer_email": "ana.perez@example.com",
        "amount": 46
      },
      "chain_context": {
        "caller_flow_definition_id": "fd-caller-xxxx",
        "caller_flow_instance_id": "fi-caller-xxxx",
        "caller_flow_slug": "order-intake",
        "caller_node_id": "node-chain-billing",
        "correlation_id": "chain-7Hq2Lw9sKd3pXa1mZr4t",
        "root_flow_instance_result_id": "fir-root-xxxx"
      }
    }
  },
  "node": {
    "node_id": "node-create-task",
    "label": "Create review task"
  }
}
```

示例运行所基于的编排器提交 31e874b.
