← 자료실로 돌아가기

리소스 상세 · 实用工具

jq:从 JSON 清单里找出想要的信息

先在官方在线练习页,用虚构任务清单学会筛选一条 JSON 数据。

본문, 예시와 라이선스는 원문을 유지합니다. 코드를 표시할 뿐 온라인으로 실행하거나 AI를 호출하지 않습니다.

리소스 상세

适合刚接触接口结果、配置文件或结构化数据的人。先看懂一个筛选表达式,再考虑在本机批量处理文件。

시작 전 준비

지원 환경
跨平台
내용 업데이트
  • 在线第一练习只需现代浏览器与虚构 JSON,不需要先安装编译工具。
  • 需要本机处理文件时,从官方 releases 选择对应操作系统/架构的程序;Windows 的程序名与路径要核对。

本轮表达式填入官方练习页的筛选框;它不是 PowerShell 命令。命令行版另按所用终端处理引号。

흔한 문제

  • JSON 键名与字符串必须使用双引号;本练习的 true 是布尔值,不是带引号的字符串。
  • 不要把访问令牌、客户记录或私人配置粘贴到在线练习页或分享链接;网页服务的运行与保存方式需按其说明核对。
  • 批量处理前保留原件,不要把输出直接覆盖输入;JSON 大数字也需额外确认精度。
  • jq 主代码 MIT 不覆盖 docs/ 文档 CC BY 3.0,也不取代 COPYING 所列组件和网站依赖条款。
공식 설치 안내 ↗

전체 본문

【小目标】从两条 JSON 记录中找出已完成的姓名,并解释条件变化为何改变输出。

【开始前准备】在线第一练习只需现代浏览器与虚构 JSON,不需要先安装编译工具。
需要本机处理文件时,从官方 releases 选择对应操作系统/架构的程序;Windows 的程序名与路径要核对。

【三步尝试】1. 打开官方练习页:访问 play.jqlang.org,清楚区分输入 JSON、筛选表达式与输出区域。只放虚构内容。
2. 准备两条虚构数据:在 JSON 输入区填入 [{"name":"Xiaobu","done":true},{"name":"Aqing","done":false}]。确认括号、逗号和双引号成对。
3. 筛选并改变一个条件:输入 .[] | select(.done == true) | .name,预期只输出 "Xiaobu"。再把第二条 done 改为 true,观察为什么会多出一个结果。

【检查结果】初始数据对应的输出是 JSON 字符串 "Xiaobu";修改第二条状态后应看到两个姓名。

【来源与许可】官方仓库 jqlang/jq;固定提交 34f7186b86743a083a589741b6cea95293524108,提交日期 2026-06-20(UTC)。2026-10-27 复核的稳定实用项目,不作为本轮实时热榜项目宣称。
jq 主代码为 MIT;本条保留完整 COPYING,不裁去其中的其他声明。COPYING 另将 docs/ 文档列为 CC BY 3.0,并列明 dtoa.c、decNumber、Heimdal、NetBSD 等组件条款与文档站依赖;主 MIT 不覆盖这些内容。本条为原创导览,不复制文档站或分发二进制。

本站只提供原创导览和官方入口,导览按 CC BY 4.0 分享;不捆绑上游源码、安装包、图标、模型或用户素材。项目许可不自动覆盖依赖、商标、模型服务或托管平台,具体分发产物须另行核对。

2026-10-27 已只读核对官方固定提交的资料、完整许可和适用声明,按资料编写这份练习;本站未安装、登录或运行上游项目,也未进行安全审计。预期结果是供你自行核对的目标,不是本站实机测试记录。

사용 방법

从两条 JSON 记录中找出已完成的姓名,并解释条件变化为何改变输出。

  1. 打开官方练习页

    访问 play.jqlang.org,清楚区分输入 JSON、筛选表达式与输出区域。只放虚构内容。

  2. 准备两条虚构数据

    在 JSON 输入区填入 [{"name":"Xiaobu","done":true},{"name":"Aqing","done":false}]。确认括号、逗号和双引号成对。

  3. 筛选并改变一个条件

    输入 .[] | select(.done == true) | .name,预期只输出 "Xiaobu"。再把第二条 done 改为 true,观察为什么会多出一个结果。

예상 출력

初始数据对应的输出是 JSON 字符串 "Xiaobu";修改第二条状态后应看到两个姓名。

2026-10-27 已只读核对官方固定提交的资料、完整许可和适用声明,按资料编写这份练习;本站未安装、登录或运行上游项目,也未进行安全审计。预期结果是供你自行核对的目标,不是本站实机测试记录。

적합한 용도

  • 适合刚接触接口结果、配置文件或结构化数据的人。先看懂一个筛选表达式,再考虑在本机批量处理文件。

사용 전 주의

  • jq 主代码为 MIT;本条保留完整 COPYING,不裁去其中的其他声明。COPYING 另将 docs/ 文档列为 CC BY 3.0,并列明 dtoa.c、decNumber、Heimdal、NetBSD 等组件条款与文档站依赖;主 MIT 不覆盖这些内容。本条为原创导览,不复制文档站或分发二进制。
  • JSON 键名与字符串必须使用双引号;本练习的 true 是布尔值,不是带引号的字符串。
  • 不要把访问令牌、客户记录或私人配置粘贴到在线练习页或分享链接;网页服务的运行与保存方式需按其说明核对。
  • 批量处理前保留原件,不要把输出直接覆盖输入;JSON 大数字也需额外确认精度。
  • jq 主代码 MIT 不覆盖 docs/ 文档 CC BY 3.0,也不取代 COPYING 所列组件和网站依赖条款。

작성자와 출처

저작자 표시
本站导览
원본 작성자
Stephen Dolan 与 jq 贡献者;COPYING 主代码版权:jq is copyright (C) 2012 Stephen Dolan
원본 버전
34f7186b86743a083a589741b6cea95293524108
라이선스 확인일
2026-10-27

고지 및 수정 내용

官方仓库 jqlang/jq;固定提交 34f7186b86743a083a589741b6cea95293524108,提交日期 2026-06-20(UTC)。2026-10-27 复核的稳定实用项目,不作为本轮实时热榜项目宣称。

전체 라이선스

CC BY 4.0

CC BY 4.0 · 전체 라이선스 읽기 ↗

원본 라이선스 · MIT

jq is copyright (C) 2012 Stephen Dolan

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



jq's documentation (everything found under the docs/ subdirectory in
the source tree) is licensed under the Creative Commons CC BY 3.0
license, which can be found at:

         https://creativecommons.org/licenses/by/3.0/

The documentation website includes a copy of Twitter's Bootstrap and
relies on Bonsai, Liquid templates and various other projects, look
them up for detailed licensing conditions.



jq incorporates David M. Gay's dtoa.c and g_fmt.c, which bear the
following notices:

dtoa.c:
The author of this software is David M. Gay.

Copyright (c) 1991, 2000, 2001 by Lucent Technologies.

Permission to use, copy, modify, and distribute this software for any
purpose without fee is hereby granted, provided that this entire notice
is included in all copies of any software which is or includes a copy
or modification of this software and in all copies of the supporting
documentation for such software.

THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
WARRANTY.  IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.

g_fmt.c:
The author of this software is David M. Gay.

Copyright (c) 1991, 1996 by Lucent Technologies.

Permission to use, copy, modify, and distribute this software for any
purpose without fee is hereby granted, provided that this entire notice
is included in all copies of any software which is or includes a copy
or modification of this software and in all copies of the supporting
documentation for such software.

THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
WARRANTY.  IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.



jq uses parts of the open source C library "decNumber", which is distributed
under the following license:


ICU License - ICU 1.8.1 and later

COPYRIGHT AND PERMISSION NOTICE

Copyright (c) 1995-2005 International Business Machines Corporation and others
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.

--------------------------------------------------------------------------------
All trademarks and registered trademarks mentioned herein are the property of their respective owners.



jv_thread.h is copied from Heimdal's lib/base/heimbase.h and some code
in jv.c is copied from Heimdal's lib/base/dll.c:


Portions Copyright (c) 2016 Kungliga Tekniska Högskolan
(Royal Institute of Technology, Stockholm, Sweden).
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.



jq uses a modified version of NetBSD implementation strptime(),
which is distributed under the following license:

Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
All rights reserved.

This code was contributed to The NetBSD Foundation by Klaus Klein.
Heavily optimised by David Laight

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

전체 라이선스 읽기 ↗

검증 범위

资料与许可已核对

只核对项目资料和许可记录;未安装运行上游项目,也未进行安全审计。

2026-10-27