{"id":15893855,"url":"https://github.com/chinanf-boy/json5-zh","last_synced_at":"2025-08-14T07:32:49.569Z","repository":{"id":90548434,"uuid":"154969413","full_name":"chinanf-boy/json5-zh","owner":"chinanf-boy","description":"🇨🇳翻译: \u003cJSON5\u003e 数据交换格式(JSON5)是JSON的超集 :heart: 校对 ✅","archived":false,"fork":false,"pushed_at":"2019-03-29T04:47:23.000Z","size":10,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T14:53:56.213Z","etag":null,"topics":["docs","json","json5","zh"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chinanf-boy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-27T13:47:46.000Z","updated_at":"2023-02-06T03:35:04.000Z","dependencies_parsed_at":"2023-07-18T11:00:46.456Z","dependency_job_id":null,"html_url":"https://github.com/chinanf-boy/json5-zh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chinanf-boy/json5-zh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fjson5-zh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fjson5-zh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fjson5-zh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fjson5-zh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chinanf-boy","download_url":"https://codeload.github.com/chinanf-boy/json5-zh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fjson5-zh/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270384320,"owners_count":24574528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-14T02:00:10.309Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docs","json","json5","zh"],"created_at":"2024-10-06T08:13:55.304Z","updated_at":"2025-08-14T07:32:49.303Z","avatar_url":"https://github.com/chinanf-boy.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# json5/json5 [![explain]][source] [![translate-svg]][translate-list]\n\n\u003c!-- [![size-img]][size] --\u003e\n\n[explain]: http://llever.com/explain.svg\n[source]: https://github.com/chinanf-boy/Source-Explain\n[translate-svg]: http://llever.com/translate.svg\n[translate-list]: https://github.com/chinanf-boy/chinese-translate-list\n[size-img]: https://packagephobia.now.sh/badge?p=Name\n[size]: https://packagephobia.now.sh/result?p=Name\n\n「 数据交换格式(JSON5)是[JSON]的超集 」\n\n[中文](./readme.md) | [english](https://github.com/json5/json5)\n\n---\n\n## 校对 ✅\n\n\u003c!-- doc-templite START generated --\u003e\n\u003c!-- repo = 'json5/json5' --\u003e\n\u003c!-- commit = '69c4a75d345a58a773148dd9c05ce74e668dc87d' --\u003e\n\u003c!-- time = '2018-09-28' --\u003e\n翻译的原文 | 与日期 | 最新更新 | 更多\n---|---|---|---\n[commit] | ⏰ 2018-09-28 | ![last] | [中文翻译][translate-list]\n\n[last]: https://img.shields.io/github/last-commit/json5/json5.svg\n[commit]: https://github.com/json5/json5/tree/69c4a75d345a58a773148dd9c05ce74e668dc87d\n\n\u003c!-- doc-templite END generated --\u003e\n\n- [x] Readme\n- [ ] 我在想[官方规范](https://json5.github.io/json5-spec/)要不要翻译，\n\n\n### 贡献\n\n欢迎 👏 勘误/校对/更新贡献 😊 [具体贡献请看](https://github.com/chinanf-boy/chinese-translate-list#贡献)\n\n## 生活\n\n[If help, **buy** me coffee —— 营养跟不上了，给我来瓶营养快线吧! 💰](https://github.com/chinanf-boy/live-need-money)\n\n---\n\n### 目录\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n\n- [JSON5 - 人类的 JSON](#json5---%E4%BA%BA%E7%B1%BB%E7%9A%84-json)\n  - [功能摘要](#%E5%8A%9F%E8%83%BD%E6%91%98%E8%A6%81)\n    - [对象-Objects](#%E5%AF%B9%E8%B1%A1-objects)\n    - [数组-Arrays](#%E6%95%B0%E7%BB%84-arrays)\n    - [字符串-Strings](#%E5%AD%97%E7%AC%A6%E4%B8%B2-strings)\n    - [数字-Numbers](#%E6%95%B0%E5%AD%97-numbers)\n    - [注释-Comments](#%E6%B3%A8%E9%87%8A-comments)\n    - [额外空格-White Space](#%E9%A2%9D%E5%A4%96%E7%A9%BA%E6%A0%BC-white-space)\n  - [简短的例子](#%E7%AE%80%E7%9F%AD%E7%9A%84%E4%BE%8B%E5%AD%90)\n  - [规范](#%E8%A7%84%E8%8C%83)\n  - [安装](#%E5%AE%89%E8%A3%85)\n    - [Node.js](#nodejs)\n    - [浏览器](#%E6%B5%8F%E8%A7%88%E5%99%A8)\n  - [API](#api)\n    - [JSON5.parse()](#json5parse)\n      - [语法参考](#%E8%AF%AD%E6%B3%95%E5%8F%82%E8%80%83)\n      - [参数](#%E5%8F%82%E6%95%B0)\n      - [返回值](#%E8%BF%94%E5%9B%9E%E5%80%BC)\n    - [JSON5.stringify()](#json5stringify)\n      - [语法参考](#%E8%AF%AD%E6%B3%95%E5%8F%82%E8%80%83-1)\n      - [参数](#%E5%8F%82%E6%95%B0-1)\n      - [返回值](#%E8%BF%94%E5%9B%9E%E5%80%BC-1)\n    - [Node.js 的JSON5 文件`require()`](#nodejs-%E7%9A%84json5-%E6%96%87%E4%BB%B6require)\n  - [CLI](#cli)\n    - [安装](#%E5%AE%89%E8%A3%85-1)\n    - [用法](#%E7%94%A8%E6%B3%95)\n      - [选项:](#%E9%80%89%E9%A1%B9)\n  - [贡献](#%E8%B4%A1%E7%8C%AE)\n    - [开发](#%E5%BC%80%E5%8F%91)\n    - [问题](#%E9%97%AE%E9%A2%98)\n  - [执照](#%E6%89%A7%E7%85%A7)\n  - [里程](#%E9%87%8C%E7%A8%8B)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n# JSON5 - 人类的 JSON\n\n[![Build Status](https://travis-ci.org/json5/json5.svg)][build status]\n[![Coverage Status](https://coveralls.io/repos/github/json5/json5/badge.svg)][coverage status]\n\n数据交换格式(JSON5)是[JSON]的超集，旨在通过从[ECMAScript 5.1]学到的些东东，来扩展JSON语法，以减轻 JSON 的一些限制.\n\n此 JavaScript 库是 JSON5 解析{parse}和序列化{serialization}库的官方参考实现.\n\n[build status]: https://travis-ci.org/json5/json5\n[coverage status]: https://coveralls.io/github/json5/json5\n[json]: https://tools.ietf.org/html/rfc7159\n[ecmascript 5.1]: https://www.ecma-international.org/ecma-262/5.1/\n\n## 功能摘要\n\n以下 (JSON 不支持) ECMSONcript 5.1 的功能已扩展成为 JSON5.\n\n### 对象-Objects\n\n- 对象 **keys** 可以是 ECMAScript 5.1 的 *[IdentifierName]*.\n- 对象可以只有一个尾随逗号.\n\n### 数组-Arrays\n\n- 数组可以只有一个尾随逗号.\n\n### 字符串-Strings\n\n- 字符串可以是单引号.\n- 字符串可以通过转义换行符，来跨越多行.\n- 字符串可以包括字符转义.\n\n### 数字-Numbers\n\n- 数字可以是十六进制的.\n- 数字可以有一个小数点，起头或尾随.\n- 数字可以是[IEEE 754]正无穷大{+infinity},负无穷大{-infinity}和 NaN.\n- 数字可以以明确的加号开头.\n\n### 注释-Comments\n\n- 允许单行和多行注释.\n\n### 额外空格-White Space\n\n- 允许使用额外的空格字符.\n\n[identifiername]: https://www.ecma-international.org/ecma-262/5.1/#sec-7.6\n[ieee 754]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933\n\n## 简短的例子\n\n```js\n{\n  // 注释\n  unquoted: 'and you can quote me on that',\n  singleQuotes: 'I can use \"double quotes\" here',\n  lineBreaks: \"Look, Mom! \\\nNo \\\\n's!\",\n  hexadecimal: 0xdecaf,\n  leadingDecimalPoint: .8675309, andTrailing: 8675309.,\n  positiveSign: +1,\n  trailingComma: 'in objects', andIn: ['arrays',],\n  \"backwardsCompatible\": \"with JSON\",\n}\n```\n\n## 规范\n\n有关 JSON5 格式的详细说明,请阅读[官方规范](https://json5.github.io/json5-spec/).\n\n## 安装\n\n### Node.js\n\n```sh\nnpm install json5\n```\n\n```js\nconst JSON5 = require('json5');\n```\n\n### 浏览器\n\n```html\n\u003cscript src=\"https://unpkg.com/json5@^2.0.0/dist/index.min.js\"\u003e\u003c/script\u003e\n```\n\n这将创造一个全局`JSON5`变量.\n\n## API\n\nJSON5 API 兼容[JSON API].\n\n[json api]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON\n\n### JSON5.parse()\n\n解析一个 JSON5 字符串，构造由字符串描述的 JavaScript 值或对象.可以提供可选的 reviver 函数 - 可在返回结果对象之前，对其执行转换.\n\n#### 语法参考\n\n```js\nJSON5.parse(text[, reviver])\n```\n\n#### 参数\n\n- `text`: 要解析为 JSON5 的字符串.\n- `reviver`: 若是一个函数,它规定了在返回之前，如何转换最初解析的生成值.\n\n#### 返回值\n\n给定 JSON5 文本的对应对象.\n\n### JSON5.stringify()\n\n将 JavaScript 值，转换为 JSON5 字符串,如果指定了 replacer 函数,则可以选择替换值,或者如果指定了 replacer 数组,则可选择要包括的指定属性.\n\n#### 语法参考\n\n``` js\nJSON5.stringify(value[, replacer[, space]])\nJSON5.stringify(value[, options])\n```\n\n#### 参数\n\n- `value`:要转换为 JSON5 字符串的值.\n- `replacer`:一个改变此过程行为的函数,或一个 String 和 Number 对象数组,的白名单。用于**选择/过滤**要包含在 JSON5 字符串中的值对象的属性.如果此值为 null 或未提供,则对象的所有属性都包含在生成的 JSON5 字符串中.\n- `space`:一个 String 或 Number 对象,用于将空格插入输出 JSON5 字符串以实现可读性。如果这是一个数字,则表示用作空格的空格字符数;这个数字的上限为 10(如果它更大,哪该值就 10 到头)。小于 1 的值表示不应使用空格。如果这是一个字符串，则该字符串(或字符串的前 10 个字符,如果长于该字符串)会被用作空格填充。如果未提供此参数(或为 null), 则不使用空格。如果使用空格,则将在对象和数组中使用尾随逗号。\n- `options`:具有以下属性的对象:\n  - `replacer`:与`replacer`参数相同.\n  - `space`:与`space`参数相同.\n  - `quote`:一个 String,表示序列化字符串时，要使用的引号字符.\n\n#### 返回值\n\n表示js值的JSON5 字符串.\n\n### Node.js 的JSON5 文件`require()`\n\n使用 Node.js 时,您可以通过添加以下语句，让 Node `require()`JSON5 文件，正常解析.\n\n```js\nrequire('json5/lib/register');\n```\n\n就这样,您已经能加载 JSON5 文件， 通过Node.js 的 `require()`声明.例如:\n\n```js\nconst config = require('./config.json5');\n```\n\n## CLI\n\n由于 JSON 比 JSON5 使用得更广泛,因此该软件包包括一个用于将 JSON5 转换为 JSON ，以及验证 JSON5 文档语法的 CLI.\n\n### 安装\n\n```sh\nnpm install --global json5\n```\n\n### 用法\n\n```sh\njson5 [options] \u003cfile\u003e\n```\n\n如果`\u003cfile\u003e`未提供,则使用 STDIN.\n\n#### 选项:\n\n- `-s`,`--space`: 缩进或缩进的空格数，也可以使用Tab的`t`\n- `-o`,`--out-file [file]`: 输出到指定文件,否则输出 STDOUT\n- `-v`,`--validate`:验证 JSON5 ，但不输出 JSON\n- `-V`,`--version`: 输出版本号\n- `-h`,`--help`:输出使用信息\n\n## 贡献\n\n### 开发\n\n```sh\ngit clone https://github.com/json5/json5\ncd json5\nnpm install\n```\n\n在提供代码时,请编写相关测试，并运行`npm test`和`npm run lint`。在提交拉取请求之前.请使用支持的编辑器[EditorConfig](http://editorconfig.org/).\n\n### 问题\n\n要报告有关 JSON5 数据格式的错误或请求功能,请向[官方规范库Issue](https://github.com/json5/json5-spec)提交问题.\n\n要报告有关 JSON5 的 JavaScript 实现的错误或请求功能,请向此存储库提交问题.\n\n## 执照\n\n麻省理工学院.看到[LICENSE.md](./LICENSE.md)详情.\n\n## 里程\n\n[Assem Kishore](https://github.com/aseemk)成立了这个项目.\n\n[Michael Bolin](http://bolinfest.com/)单人扛鼎，并发表了一些相同的想法与**awesome**的解释和细节.推荐阅读:[JSON 改进的建议](http://bolinfest.com/essays/json.html)\n\n[Douglas Crockford](http://www.crockford.com/)，当然他设计和构建了 JSON,但是他[JSON 网站](http://json.org/)上的状态机图，虽然听起来很俗气,但却让我们有动力和信心, 兼触手可及的，建立一个新的解析器来实现这些想法! JSON5 的原始实现也直接模仿 Doug 的开源[json_parse.js]解析器.我们非常感谢这些干净，且记录良好的代码.\n\n[json_parse.js]: https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js\n\n[Max Nanasy](https://github.com/MaxNanasy)一直是一个早期和的积极贡献的支持者,贡献了多个补丁和想法.\n\n[Andrew Eisenberg](https://github.com/aeisenberg)贡献了原始的`stringify`方法.\n\n[Jordan Tucker](https://github.com/jordanbtucker)已经将 JSON5 与 ES5 更紧密地结合在一起,编写了官方 JSON5 规范,从头开始完全重写代码库,并积极维护这个项目.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchinanf-boy%2Fjson5-zh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchinanf-boy%2Fjson5-zh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchinanf-boy%2Fjson5-zh/lists"}