{"id":19219954,"url":"https://github.com/huanghaiyang/jsonmock","last_synced_at":"2025-08-11T06:48:55.825Z","repository":{"id":57285803,"uuid":"64647209","full_name":"huanghaiyang/jsonmock","owner":"huanghaiyang","description":"json data mock framework","archived":false,"fork":false,"pushed_at":"2016-08-04T02:01:37.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T09:16:33.370Z","etag":null,"topics":["fakerjs","json","mock","mock-data"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huanghaiyang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-01T07:51:10.000Z","updated_at":"2019-06-16T14:18:11.000Z","dependencies_parsed_at":"2022-09-16T22:40:42.357Z","dependency_job_id":null,"html_url":"https://github.com/huanghaiyang/jsonmock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/huanghaiyang/jsonmock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huanghaiyang%2Fjsonmock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huanghaiyang%2Fjsonmock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huanghaiyang%2Fjsonmock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huanghaiyang%2Fjsonmock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huanghaiyang","download_url":"https://codeload.github.com/huanghaiyang/jsonmock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huanghaiyang%2Fjsonmock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269734044,"owners_count":24466545,"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-10T02:00:08.965Z","response_time":71,"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":["fakerjs","json","mock","mock-data"],"created_at":"2024-11-09T14:33:24.661Z","updated_at":"2025-08-11T06:48:55.772Z","avatar_url":"https://github.com/huanghaiyang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsonmock\njson mock framework\n\n## install \n```\nnpm install jsonmock --save\n```\n\n## test\n```\nnpm install\nnpm test\n```\n\n## build\n```\nnpm run build\n```\n\n## how to use\n```javascript\nvar jsonmock = require('../lib/index')\nvar user = jsonmock('./tests/data/user.json')\n```\n\nuser.json must be like this:\n\n```json\n{\n\t\"name\": chance.name(),\n\t\"age\": chance.age(),\n\t\"cf\": chance.cf(),\n\t\"birthday\": chance.birthday(),\n\t\"location\": {\n\t\t\"address\": chance.address(),\n\t\t\"country\": chance.country(),\n\t\t\"phone\": chance.phone(),\n\t\t\"city\": faker.address.city(),\n\t\t\"streetName\": (() =\u003e {\n\t\t\treturn faker.address.streetName()\n\t\t})()\n\t}\n}\n```\n\nyou can use [chance](http://chancejs.com/) or [faker](http://marak.github.io/faker.js/) to generate a mock data, or use ```(()=\u003e{})()``` to caculate, but it does not support other libs or funcs.\n\nif you want get an user array, please use like this:\n\n```javascript\nvar users = jsonmock('./tests/data/user.json', {\n\tlength: 10\n})\nassert.equal(users.length, 10)\n```\nuser ```@import``` to include another ```.json```, let's watch ```web.json```\n\n```json\n{\n\t\"domain\": chance.domain(),\n\t\"ip\": @import \"./tests/data/ip.json\"\n}\n```\nip.json\n```\n{\n\t\"ipv4\": chance.ip(),\n\t\"ipv6\": chance.ipv6() \n}\n```\n\u003cfont color=red\u003eremeber, it does not support recursive ```@import``` in ```ip.json```\u003c/font\u003e\n\nyou may use jsonmock to mock paganition...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuanghaiyang%2Fjsonmock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuanghaiyang%2Fjsonmock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuanghaiyang%2Fjsonmock/lists"}