Skip to content

Commit 7f1385f

Browse files
authored
Merge pull request #28656 from gaoguangze111/update-chinese-page-jsonpath
Update Chinese page jsonpath
2 parents a909bd7 + 86984f2 commit 7f1385f

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

content/zh/docs/reference/kubectl/jsonpath.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: JSONPath 支持
33
content_type: concept
44
weight: 25
55
---
6-
<!--
6+
<!--
77
---
88
title: JSONPath Support
99
content_type: concept
@@ -13,43 +13,43 @@ weight: 25
1313

1414
<!-- overview -->
1515
<!--
16-
Kubectl supports JSONPath template.
16+
Kubectl supports JSONPath template.
1717
-->
1818
Kubectl 支持 JSONPath 模板。
1919

2020

2121
<!-- body -->
2222

23-
<!--
23+
<!--
2424
JSONPath template is composed of JSONPath expressions enclosed by curly braces {}.
2525
Kubectl uses JSONPath expressions to filter on specific fields in the JSON object and format the output.
26-
In addition to the original JSONPath template syntax, the following functions and syntax are valid:
26+
In addition to the original JSONPath template syntax, the following functions and syntax are valid:
2727
-->
2828
JSONPath 模板由 {} 包起来的 JSONPath 表达式组成。Kubectl 使用 JSONPath 表达式来过滤 JSON 对象中的特定字段并格式化输出。除了原始的 JSONPath 模板语法,以下函数和语法也是有效的:
2929

30-
<!--
30+
<!--
3131
1. Use double quotes to quote text inside JSONPath expressions.
3232
2. Use the `range`, `end` operators to iterate lists.
33-
3. Use negative slice indices to step backwards through a list. Negative indices do not "wrap around" a list and are valid as long as `-index + listLength >= 0`.
33+
3. Use negative slice indices to step backwards through a list. Negative indices do not "wrap around" a list and are valid as long as `-index + listLength >= 0`.
3434
-->
3535
1. 使用双引号将 JSONPath 表达式内的文本引起来。
3636
2. 使用 `range``end` 运算符来迭代列表。
3737
3. 使用负片索引后退列表。负索引不会“环绕”列表,并且只要 `-index + listLength> = 0` 就有效。
3838

3939
{{< note >}}
40-
<!--
40+
<!--
4141
- The `$` operator is optional since the expression always starts from the root object by default.
4242
43-
- The result object is printed as its String() function.
43+
- The result object is printed as its String() function.
4444
-->
4545
- `$` 运算符是可选的,因为默认情况下表达式总是从根对象开始。
4646

4747
- 结果对象将作为其 String() 函数输出。
4848

4949
{{< /note >}}
5050

51-
<!--
52-
Given the JSON input:
51+
<!--
52+
Given the JSON input:
5353
-->
5454
给定 JSON 输入:
5555

@@ -90,7 +90,7 @@ Given the JSON input:
9090
}
9191
```
9292

93-
<!--
93+
<!--
9494
Function | Description | Example | Result
9595
--------------------|---------------------------|-----------------------------------------------------------------|------------------
9696
`text` | the plain text | `kind is {.kind}` | `kind is List`
@@ -102,7 +102,7 @@ Function | Description | Example
102102
`[,]` | union operator | `{.items[*]['metadata.name', 'status.capacity']}` | `127.0.0.1 127.0.0.2 map[cpu:4] map[cpu:8]`
103103
`?()` | filter | `{.users[?(@.name=="e2e")].user.password}` | `secret`
104104
`range`, `end` | iterate list | `{range .items[*]}[{.metadata.name}, {.status.capacity}] {end}` | `[127.0.0.1, map[cpu:4]] [127.0.0.2, map[cpu:8]]`
105-
`''` | quote interpreted string | `{range .items[*]}{.metadata.name}{'\t'}{end}` | `127.0.0.1 127.0.0.2`
105+
`''` | quote interpreted string | `{range .items[*]}{.metadata.name}{'\t'}{end}` | `127.0.0.1 127.0.0.2`
106106
-->
107107
函数 | 描述 | 示例 | 结果
108108
--------------------|---------------------------|-----------------------------------------------------------------|------------------
@@ -117,8 +117,8 @@ Function | Description | Example
117117
`range`, `end` | 迭代列表 | `{range .items[*]}[{.metadata.name}, {.status.capacity}] {end}` | `[127.0.0.1, map[cpu:4]] [127.0.0.2, map[cpu:8]]`
118118
`''` | 引用解释执行字符串 | `{range .items[*]}{.metadata.name}{'\t'}{end}` | `127.0.0.1 127.0.0.2`
119119

120-
<!--
121-
Examples using `kubectl` and JSONPath expressions:
120+
<!--
121+
Examples using `kubectl` and JSONPath expressions:
122122
-->
123123
使用 `kubectl` 和 JSONPath 表达式的示例:
124124

@@ -131,7 +131,7 @@ kubectl get pods -o=jsonpath="{.items[*]['metadata.name', 'status.capacity']}"
131131
kubectl get pods -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.startTime}{"\n"}{end}'
132132
```
133133

134-
<!--
134+
<!--
135135
{{< note >}}
136136
On Windows, you must _double_ quote any JSONPath template that contains spaces (not single quote as shown above for bash). This in turn means that you must use a single quote or escaped double quote around any literals in the template. For example:
137137
@@ -142,7 +142,7 @@ kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{\"\t\"}{.status.
142142
{{< /note >}}
143143
-->
144144
{{< note >}}
145-
在 Windows 上,您必须用双引号把任何包含空格的 JSONPath 模板(不是上面 bash 所示的单引号)。
145+
在 Windows 上,对于任何包含空格的 JSONPath 模板,您必须使用双引号(不是上面 bash 所示的单引号)。
146146
反过来,这意味着您必须在模板中的所有文字周围使用单引号或转义的双引号。
147147
例如:
148148

@@ -176,4 +176,3 @@ kubectl get pods -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.nam
176176
kubectl get pods -o json | jq -r '.items[] | select(.metadata.name | test("test-")).spec.containers[].image'
177177
```
178178
{{< /note >}}
179-

0 commit comments

Comments
 (0)