{"id":16627141,"url":"https://github.com/ttulka/json-mock-data-generator","last_synced_at":"2025-04-28T11:21:12.917Z","repository":{"id":53608825,"uuid":"89325107","full_name":"ttulka/json-mock-data-generator","owner":"ttulka","description":"JSON Mock Data Generator","archived":false,"fork":false,"pushed_at":"2023-04-14T17:28:01.000Z","size":341,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-25T12:07:36.694Z","etag":null,"topics":["generator","java","json","json-generator","mock","mock-data"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ttulka.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":"2017-04-25T06:25:12.000Z","updated_at":"2024-09-02T13:21:11.000Z","dependencies_parsed_at":"2022-08-27T04:21:10.029Z","dependency_job_id":null,"html_url":"https://github.com/ttulka/json-mock-data-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fjson-mock-data-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fjson-mock-data-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fjson-mock-data-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fjson-mock-data-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttulka","download_url":"https://codeload.github.com/ttulka/json-mock-data-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251302769,"owners_count":21567601,"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","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":["generator","java","json","json-generator","mock","mock-data"],"created_at":"2024-10-12T04:13:32.556Z","updated_at":"2025-04-28T11:21:12.899Z","avatar_url":"https://github.com/ttulka.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Mock Data Generator\n\nA simple tool for generating JSON mock data based on the configurable structure.\n\nThere are a lot of online tools for similar usage like [JSON Generator](http://www.json-generator.com) but all of them have a little problem - they fail when generating a big amount of data (milions of elements). For this purpose a local processing must be used.\n\n## Features\n\nThe tool provides a simple configurable definition of the generated result:\n\n- user-defined structure of a document (sub-elements),\n- user-defined repeat of element,\n- pre-defined value generators like name, e-mail, phone, etc.\n- including a content of a local file,\n- random values (numbers, dates, strings) with minimums and maximuns or\n- random selection from a user-defined set.\n\n## Configuration\n\nExample configuration files could be found in the `/examples` folder.\nThe sample outputs from those configurations are in the same folder with a suffix `.out`.\n\nConfiguration is a [JSON](http://www.json.org) file with the following formal definition:\n\n- The root element `items` is an array,\n- each non-root element must define an attribute `name`,\n- any element can define children elements as an array element `items`,\n- if no `repeat` attribute is defined there is only one *composite* child element,\n- a composite element can define an attribute `repeat` - \"min[,max]\" (default 1),\n- if a composite element define an attribute `repeat` children elements are in an array,\n- an element can define a `value` or `values` (comma-separated values) attribute,\n- an array element has the type `array` and must define `values`,\n- if an element doesn't define a value(s), must define a `type` attribute,\n- types of elements are following:\n\t- `integer`, a random int number, can be limited with `min` and `max` attributes,\n\t- `float`, a random float number, can be limited with `min` and `max` attributes,\n\t- `date`, a random date, can be limited with `min` and `max` attributes,\n\t- `lorem`, a random \"Lorem Ipsum\" text, can be limited with `min` and `max` attributes,\n\t- `id`, a random ID string, \n\t- `fullName`, a random full name,\n\t- `firstName`, a random first name,\n\t- `lastName`, a random last name,\n\t- `title`, a random title,\n\t- `email`, a random e-mail address,\n\t- `phone`, a random phone number,\n\t- `address`, a random address (street, zip and city),\n\t- `file`, loads the content from a local file, must define a `path` attribute as a path to a file related to the execution folder.\n\t\nA very simple configuration file could look like this:\n\n```\n{\n  \"items\": [\n    {\n      \"name\": \"header\",\n      \"value\": \"Example configuration file for a medicinal data.\"\n    },\n    {\n      \"name\": \"patients\",\n      \"repeat\": \"100\",\n      \"items\": [\n        {\n          \"name\": \"personalId\",\n          \"type\": \"id\"\n        },\n        {\n          \"name\": \"name\",\n          \"type\": \"fullName\"\n        },\n        {\n          \"name\": \"gender\",\n          \"values\": \"male, female\"\n        },\n        {\n          \"name\": \"age\",\n          \"type\": \"integer\",\n          \"min\": \"20\",\n          \"max\": \"100\"\n        },\n        {\n          \"name\": \"contact\",\n          \"type\": \"phone\"\n        },\n        {\n          \"name\": \"home\",\n          \"type\": \"address\"\n        },\n        {\n          \"name\": \"doctor\",\n          \"items\": [\n            {\n              \"name\": \"title\",\n              \"type\": \"title\"\n            },\n            {\n              \"name\": \"name\",\n              \"type\": \"fullName\"\n            },\n            {\n              \"name\": \"departments\",\n              \"type\": \"array\",\n              \"repeat\": \"1,3\",\n              \"values\": \"ICU, EU, ED, CCU, HF\"\n            }\n          ]\n        }\n      ]\n    },\n    {\n      \"name\": \"updated\",\n      \"type\": \"date\",\n      \"min\": \"1990-01-01\"\n    },\n    {\n      \"name\": \"footer\",\n      \"type\": \"file\",\n      \"path\": \"footer.txt\"\n    }\n  ]\n}\n```\n\t\n## Running\n\nFirst, clone or fork the repository:\n\n```\n$ git clone git@github.com:ttulka/json-mock-data-generator.git\n$ cd json-mock-data-generator\n```\nNow build it:\n```\n$ mvn clean package\n```\nOnce this is completed a jar file has been generated in the target folder.\n\nAnd finally run it: \n\n```\n$ java -jar target/json-mock-data-generator-\u003cversion\u003e.jar\n```\n\nFor test purposes example configurations could be used:\n\n```\n\u003e Configuration file: examples/simple.json\n```\nor\n```\n\u003e Configuration file: examples/full.json\n```  \n\n### Generating a set of files\n\nTo generate more than only one file based on the same configuration it is possible to define how many file creates the generator:\n\n```\n$ java -jar target/json-mock-data-generator-\u003cversion\u003e.jar --files 100\n```\n\nNow hundred files will be generated.\n\n## Guess Configuration from a JSON document\n\nTo save the effort with defining a configuration files for complex structures there is a possibility to let the program guess the configuration from an example JSON document.\nThe generated configuration file could be then manually adapt especially in the meaning of the element types.\n\n``\n$ java -jar target/json-mock-data-generator-\u003cversion\u003e.jar --guess \u003cpath-to-json-file\u003e\n``\n\nThe configuration guess will be generated into `\u003cpath-to-json-file\u003e.guess-conf` file.\n\n## License\n\n[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttulka%2Fjson-mock-data-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttulka%2Fjson-mock-data-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttulka%2Fjson-mock-data-generator/lists"}