{"id":18490628,"url":"https://github.com/jiadi0801/mock-yaml","last_synced_at":"2026-04-30T09:33:13.936Z","repository":{"id":57300134,"uuid":"94868194","full_name":"jiadi0801/mock-yaml","owner":"jiadi0801","description":"用简洁的yaml语法写mock文件，告别繁杂的json引号","archived":false,"fork":false,"pushed_at":"2017-08-07T03:42:27.000Z","size":228,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-21T04:07:29.383Z","etag":null,"topics":["mockjs","yaml"],"latest_commit_sha":null,"homepage":"http://jiadi0801.github.io/convert.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jiadi0801.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-20T08:32:17.000Z","updated_at":"2023-03-08T22:48:33.000Z","dependencies_parsed_at":"2022-08-26T18:21:55.248Z","dependency_job_id":null,"html_url":"https://github.com/jiadi0801/mock-yaml","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jiadi0801/mock-yaml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiadi0801%2Fmock-yaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiadi0801%2Fmock-yaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiadi0801%2Fmock-yaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiadi0801%2Fmock-yaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiadi0801","download_url":"https://codeload.github.com/jiadi0801/mock-yaml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiadi0801%2Fmock-yaml/sbom","scorecard":{"id":519387,"data":{"date":"2025-08-11","repo":{"name":"github.com/jiadi0801/mock-yaml","commit":"b12add9af6f28f504a10c124ea152d12b2302860"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-20T02:35:34.960Z","repository_id":57300134,"created_at":"2025-08-20T02:35:34.961Z","updated_at":"2025-08-20T02:35:34.961Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32460781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"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":["mockjs","yaml"],"created_at":"2024-11-06T13:00:10.963Z","updated_at":"2026-04-30T09:33:13.896Z","avatar_url":"https://github.com/jiadi0801.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mock-yaml\n用yaml语法作为数据结构，兼容绝大部分[mockjs](https://github.com/nuysoft/Mock)语法，同时获得yaml的强大扩展能力。\n\n## 安装\n服务端npm安装\n```\n$ npm install mock-yaml --save-dev\n```\n客户端引入script脚本\n```\n\u003cscript src=\"dist/mockyaml.js\"\u003e\u003c/script\u003e\n```\n\n## 使用\n### 使用示例\n见[how to use](https://github.com/jiadi0801/mock-yaml/blob/master/doc/howtouse.md)\n### 方法\n* toJSON: 将yaml文件转成json\n* toYAML: 将json转成yaml，暂不支持mockjs规则自动转成yaml语法的规则\n* Random: 扩展mockjs的占位符，也即Mock.Random\n* Mock: mockjs对象\n\n## 相关文档\n* [阮一峰yaml介绍](http://www.ruanyifeng.com/blog/2016/07/yaml.html)\n* [js-yaml](http://nodeca.github.io/js-yaml/)\n* [mockjs示例](http://mockjs.com/examples.html)\n\n## TODO\n* [todo] xhr mock，增强且覆盖尽可能多的库\n* [todo] 增加mock占位符\n* [todo] 转换器页面增加链接到GitHub主页\n\n## mockjs模板在mock-yaml的语法\n```\n属性：规则模板         具体规则   初始值\nkey:  !str/min-max     1-3        ★\n```\n\n## mockjs数据模板\n|类型              | mockjs数据模板      | mock-yaml示例语法         | 示例结果          | 备注  |\n|------------------|---------------------|---------------------------|-------------------|-------|\n|string            | min-max             | key: !str/min-max 1-3 ★  | {key: \"★★\"}     |       |\n|string            | count               | key: !str/count 4 ★      | {key: \"★★★★\"} |       |\n|number            | min-max             | key: !num/min-max -10-10 1| {key: -3}         |       |\n|number            | min-max.dmin-dmax   | key: !num/min-max.dmin-dmax 1-10.2-3  10 | {key: 9.77} |        |\n|number            | min-max.dcount      | key: !num/min-max.dcount 1-10.3 1 | {key: 1.104}  |        |\n|number            | count.dmin-dmax     | key: !num/count.dmin-dmax -30.1-2 1 | {key: -30.9} |        |\n|number            | count.dcount        | key: !num/count.dcount -23.4 1 | {key: -23.7824}  |        |\n|number            | count               |                  |  | 没有实现     |\n|number            | +step               |                  |  | 没有实现     |\n|boolean           | 1                   | key: !bool/1     | {key: false} | 可以只写规则模板!bool/1，不用写具体规则和初始值|\n|boolean           | min-max             | key: !bool/min-max 1-3 true  | {key: false} |        |\n|object            | count               |                  |  | 见示例       |\n|object            | min-max             |                  |  | 见示例       |\n|array             | 1                   |                  |  | 见示例       |\n|array             | +1                  |                  |  | 没有实现     |\n|array             | min-max             |                  |  | 见示例       |\n|array             | count               |                  |  | 见示例       |\n|function          | !!js/function \u003e     |                  |  | yaml内置     |\n|regexp            |                     |                  |  | 见示例       |\n|regexp            | min-max             |                  |  | 没有实现       |\n## mockjs占位符\n|类型              | 占位符            | 兼容(default Y) | 备注  |\n|------------------|-------------------|------------|-------|\n|all               | all               |   Y        |       |\n\n## 注意事项\nyml语法的`@`字符已被保留，所以如果存在以`@`为首字母的字符串（比如说mockjs的占位符），那么需要用引号将其包裹起来，如果`@`不是首字母，那么可以省略引号。\n``` yaml\nplaceholder: \n    - '@url'\n    - hello @string(5,10)\n```\n\n## 示例\n* file.yml\n```yaml\nroot: \n  str:\n    -10--1: !str/min-max -10--1 ★\n    1-10: !str/min-max 1-10 ★\n    4: !str/count 4 ★\n  number:\n    -10-10: !num/min-max -10-10  1\n    1-10.2-3: !num/min-max.dmin-dmax 1-10.2-3  10\n    -10-1.1-4: !num/min-max.dmin-dmax -10-1.1-4  10\n    1-10.3: !num/min-max.dcount 1-10.3 1\n    1-10.-3: !num/min-max.dcount 1-10.-3 1\n    -30.1-2: !num/count.dmin-dmax -30.1-2 1\n    -23.4: !num/count.dcount -23.4 1\n  boolean:\n    anychar: !bool/1 1 1\n    true1-3: !bool/min-max 1-3 true\n    false1-3: !bool/min-max 1-3 false\n  object:\n    2: \u0026aliasobj1  !object/count\n      /rule: 2\n      310000: 北京市\n      320000: 江苏省\n      330000: 浙江省\n      340000: 安徽省\n    1-3: \u0026aliasobj2 !object/count\n      /rule: 1-3\n      310000: 北京市\n      320000: 江苏省\n      330000: 浙江省\n      340000: 安徽省\n  array:\n    1-3: !array/min-max \u0026alias1\n      - 1-3\n      - 北京市\n      - 江苏省\n      - 浙江省\n      - 安徽省\n    2: !array/count \n      - 2\n      - 北京市\n      - 江苏省\n      - 浙江省\n      - 安徽省\n  func: !!js/function \u003e\n      function foobar() {\n        return 'Wow! JS-YAML Rocks!';\n      }\n  regexp: \n    - !regexp/1 /[a-z][A-Z][0-9]/\n    - !regexp/1 /\\w\\W\\s\\S\\d\\D/\n    - !regexp/1 /\\d{5,10}/\n    - !regexp/1 /@color/\n  placeholder:\n    - '@check' \n    - '@url'\n    - hello @string(5,10)\n    - '@now'\n  alias: *alias1\n  aliasobj: \n    \u003c\u003c: *aliasobj1\n    \u003c\u003c: *aliasobj2\n```\n\n* json\n```json\n{\n  \"root\": {\n    \"str\": {\n      \"4\": \"★★★★\",\n      \"-10--1\": \"\",\n      \"1-10\": \"★★★★★★★\"\n    },\n    \"number\": {\n      \"-10-10\": 2,\n      \"1-10.2-3\": 9.361,\n      \"-10-1.1-4\": -8.07,\n      \"1-10.3\": 2.412,\n      \"1-10.-3\": 8.6158,\n      \"-30.1-2\": -30.37,\n      \"-23.4\": -23.9829\n    },\n    \"boolean\": {\n      \"anychar\": false,\n      \"true1-3\": false,\n      \"false1-3\": false\n    },\n    \"object\": {\n      \"2\": {\n        \"310000\": \"北京市\",\n        \"320000\": \"江苏省\"\n      },\n      \"1-3\": {\n        \"310000\": \"北京市\",\n        \"330000\": \"浙江省\",\n        \"340000\": \"安徽省\"\n      }\n    },\n    \"array\": {\n      \"2\": [\n        \"北京市\",\n        \"江苏省\",\n        \"浙江省\",\n        \"安徽省\",\n        \"北京市\",\n        \"江苏省\",\n        \"浙江省\",\n        \"安徽省\"\n      ],\n      \"1-3\": [\n        \"北京市\",\n        \"江苏省\",\n        \"浙江省\",\n        \"安徽省\",\n        \"北京市\",\n        \"江苏省\",\n        \"浙江省\",\n        \"安徽省\"\n      ]\n    },\n    \"regexp\": [\n      \"fG8\",\n      \"V@\u2028u1\\\"\",\n      \"54677466\",\n      \"#79f2af\"\n    ],\n    \"placeholder\": [\n      \"extend success\",\n      \"tn3270://vdqsmnf.sa/weo\",\n      \"hello GmFmah\",\n      \"2017-06-21 22:42:15\"\n    ],\n    \"alias\": [\n      \"北京市\",\n      \"江苏省\",\n      \"浙江省\",\n      \"安徽省\",\n      \"北京市\",\n      \"江苏省\",\n      \"浙江省\",\n      \"安徽省\"\n    ],\n    \"aliasobj\": {\n      \"310000\": \"北京市\",\n      \"320000\": \"江苏省\",\n      \"330000\": \"浙江省\",\n      \"340000\": \"安徽省\"\n    },\n    \"func\": \"Wow! JS-YAML Rocks!\"\n  }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiadi0801%2Fmock-yaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiadi0801%2Fmock-yaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiadi0801%2Fmock-yaml/lists"}