jsondatafaker


Namejsondatafaker JSON
Version 1.0.1 PyPI version JSON
download
home_page
SummaryGenerate and Save Fake JSON defining the schema with Yaml
upload_time2023-11-17 16:54:41
maintainer
docs_urlNone
authorNecati Arslan
requires_python
license
keywords
VCS
bugtrack_url
requirements certifi charset-normalizer docutils faker-education idna importlib-metadata jaraco.classes keyring markdown-it-py mdurl more-itertools nh3 pkginfo pygments readme-renderer requests requests-toolbelt rfc3986 rich twine urllib3 zipp faker python-dateutil pyyaml six
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # json Faker
jsondatafaker is a versatile Python package that empowers you to effortlessly create realistic but synthetic json data for a wide range of applications. If you need to generate test data for software development, this tool simplifies the process with an intuitive schema definition in YAML format.

### Key Features
**Schema Definition:** Define your target schema using a simple YAML file. Specify the structure of your JSON, attribute names and fake data generation code.

**Faker and Randomization:** Leverage the power of the Faker library and random data generation to create authentic-looking fake data that mimics real-world scenarios.

### Installation
```bash 
pip install jsondatafaker
```

### Sample Yaml File
```
version: 1
config:
  locale: en_US #faker locale Default:en_US
json:
  first_name: fake.first_name()
  last_name: fake.last_name()
  is_alive: fake.pybool()
  age: fake.random_int(18, 90)
  dob: fake.date_of_birth()
  address:
    street_address: fake.street_address()
    city: fake.city()
    state: fake.state_abbr()
    postal_code: fake.postcode()
  phone_numbers:
    - type: "\"home\""
      number: fake.phone_number()
    - type: "\"office\""
      number: fake.phone_number()
  children:
    - fake.first_name()
    - fake.first_name()
    - fake.first_name()
  spouse: null
```
[full yml example](tests/test_json.yaml)

### Sample Code
```python
import jsondatafaker

#generate json only to work with
json_data = jsondatafaker.generate_json("tests/test_json.yaml")
print(json_data["first_name"])

# export in json format
jsondatafaker.to_json("test_json.yaml", "./target_folder")
```

### Sample CLI Command
You can use jsondatafaker in your terminal for adhoc needs or shell script to automate fake data generation. \
Faker custom providers and custom functions are not supported in CLI.
```bash

# exports to current folder in json format
jsondatafaker --config test_json.yaml

# exports to target folder in json format
jsondatafaker --config test_json.yaml --target ./target_folder 

# exports to target file in json format 
jsondatafaker --config test_json.yaml --target ./target_folder/target_file.json
```

### Sample JSON Output
```json
{
    "first_name": "Michael",
    "last_name": "Cunningham",
    "is_alive": false,
    "age": 55,
    "dob": "1954-01-04",
    "address": {
        "street_address": "68878 Stephanie Walk",
        "city": "Port Jeremy",
        "state": "MT",
        "postal_code": "47702"
    },
    "phone_numbers": [
        {
            "type": "home",
            "number": "(792)887-9048"
        },
        {
            "type": "office",
            "number": "+1-901-428-8816x568"
        }
    ],
    "children": [
        "Katelyn",
        "Jenna",
        "Barbara"
    ],
    "spouse": null
}
```

### Custom Functions and Faker Providers
With json Faker, you have the flexibility to provide your own custom functions to generate column data. This advanced feature empowers developers to create custom fake data generation logic that can pull data from a database, API, file, or any other source as needed. You can also supply multiple functions in a list, allowing for even more versatility. The custom function you provide should return a single value, giving you full control over your synthetic data generation.

```python
from jsondatafaker import jsondatafaker
from faker import Faker
from faker_education import SchoolProvider #import custom faker provider

fake = Faker()
def get_level():
    return f"level {fake.random_int(1, 5)}"


jsondatafaker.to_json("test_json.yaml", "./target_folder", fake_provider=SchoolProvider, custom_function=get_level)
#multiple fake provider or custom function in a list is also works
```
Add get_level() function and custom faker provider to your yaml file
```
version: 1
config:
  locale: en_US #faker locale Default:en_US
json:
  first_name: fake.first_name()
  last_name: fake.last_name()
  is_alive: fake.pybool()
  age: fake.random_int(18, 90)
  dob: fake.date_of_birth()
  level: get_level()            # custom function
  school: fake.school_name()    # customer faker provider
```


### Faker Functions List
https://faker.readthedocs.io/en/master/providers.html#

### Bug Report & New Feature Request
https://github.com/necatiarslan/json-datafaker/issues/new 


### Todo
- 

### Nice To Have
- 

Follow me on linkedin to get latest news \
https://www.linkedin.com/in/necati-arslan/

Thanks, \
Necati ARSLAN \
necatia@gmail.com

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "jsondatafaker",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Necati Arslan",
    "author_email": "necatia@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/78/f3/51acd62a06d41f38a722d737423620b2b229821bd6491bbc65bf27ad6967/jsondatafaker-1.0.1.tar.gz",
    "platform": null,
    "description": "# json Faker\njsondatafaker is a versatile Python package that empowers you to effortlessly create realistic but synthetic json data for a wide range of applications. If you need to generate test data for software development, this tool simplifies the process with an intuitive schema definition in YAML format.\n\n### Key Features\n**Schema Definition:** Define your target schema using a simple YAML file. Specify the structure of your JSON, attribute names and fake data generation code.\n\n**Faker and Randomization:** Leverage the power of the Faker library and random data generation to create authentic-looking fake data that mimics real-world scenarios.\n\n### Installation\n```bash \npip install jsondatafaker\n```\n\n### Sample Yaml File\n```\nversion: 1\nconfig:\n  locale: en_US #faker locale Default:en_US\njson:\n  first_name: fake.first_name()\n  last_name: fake.last_name()\n  is_alive: fake.pybool()\n  age: fake.random_int(18, 90)\n  dob: fake.date_of_birth()\n  address:\n    street_address: fake.street_address()\n    city: fake.city()\n    state: fake.state_abbr()\n    postal_code: fake.postcode()\n  phone_numbers:\n    - type: \"\\\"home\\\"\"\n      number: fake.phone_number()\n    - type: \"\\\"office\\\"\"\n      number: fake.phone_number()\n  children:\n    - fake.first_name()\n    - fake.first_name()\n    - fake.first_name()\n  spouse: null\n```\n[full yml example](tests/test_json.yaml)\n\n### Sample Code\n```python\nimport jsondatafaker\n\n#generate json only to work with\njson_data = jsondatafaker.generate_json(\"tests/test_json.yaml\")\nprint(json_data[\"first_name\"])\n\n# export in json format\njsondatafaker.to_json(\"test_json.yaml\", \"./target_folder\")\n```\n\n### Sample CLI Command\nYou can use jsondatafaker in your terminal for adhoc needs or shell script to automate fake data generation. \\\nFaker custom providers and custom functions are not supported in CLI.\n```bash\n\n# exports to current folder in json format\njsondatafaker --config test_json.yaml\n\n# exports to target folder in json format\njsondatafaker --config test_json.yaml --target ./target_folder \n\n# exports to target file in json format \njsondatafaker --config test_json.yaml --target ./target_folder/target_file.json\n```\n\n### Sample JSON Output\n```json\n{\n    \"first_name\": \"Michael\",\n    \"last_name\": \"Cunningham\",\n    \"is_alive\": false,\n    \"age\": 55,\n    \"dob\": \"1954-01-04\",\n    \"address\": {\n        \"street_address\": \"68878 Stephanie Walk\",\n        \"city\": \"Port Jeremy\",\n        \"state\": \"MT\",\n        \"postal_code\": \"47702\"\n    },\n    \"phone_numbers\": [\n        {\n            \"type\": \"home\",\n            \"number\": \"(792)887-9048\"\n        },\n        {\n            \"type\": \"office\",\n            \"number\": \"+1-901-428-8816x568\"\n        }\n    ],\n    \"children\": [\n        \"Katelyn\",\n        \"Jenna\",\n        \"Barbara\"\n    ],\n    \"spouse\": null\n}\n```\n\n### Custom Functions and Faker Providers\nWith json Faker, you have the flexibility to provide your own custom functions to generate column data. This advanced feature empowers developers to create custom fake data generation logic that can pull data from a database, API, file, or any other source as needed. You can also supply multiple functions in a list, allowing for even more versatility. The custom function you provide should return a single value, giving you full control over your synthetic data generation.\n\n```python\nfrom jsondatafaker import jsondatafaker\nfrom faker import Faker\nfrom faker_education import SchoolProvider #import custom faker provider\n\nfake = Faker()\ndef get_level():\n    return f\"level {fake.random_int(1, 5)}\"\n\n\njsondatafaker.to_json(\"test_json.yaml\", \"./target_folder\", fake_provider=SchoolProvider, custom_function=get_level)\n#multiple fake provider or custom function in a list is also works\n```\nAdd get_level() function and custom faker provider to your yaml file\n```\nversion: 1\nconfig:\n  locale: en_US #faker locale Default:en_US\njson:\n  first_name: fake.first_name()\n  last_name: fake.last_name()\n  is_alive: fake.pybool()\n  age: fake.random_int(18, 90)\n  dob: fake.date_of_birth()\n  level: get_level()            # custom function\n  school: fake.school_name()    # customer faker provider\n```\n\n\n### Faker Functions List\nhttps://faker.readthedocs.io/en/master/providers.html#\n\n### Bug Report & New Feature Request\nhttps://github.com/necatiarslan/json-datafaker/issues/new \n\n\n### Todo\n- \n\n### Nice To Have\n- \n\nFollow me on linkedin to get latest news \\\nhttps://www.linkedin.com/in/necati-arslan/\n\nThanks, \\\nNecati ARSLAN \\\nnecatia@gmail.com\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Generate and Save Fake JSON defining the schema with Yaml",
    "version": "1.0.1",
    "project_urls": {
        "Documentation": "https://github.com/necatiarslan/json-datafaker/blob/main/README.md",
        "Source": "https://github.com/necatiarslan/json-datafaker"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ff6be410d474180cc90fc8843d9df4dd7e658dd81cb31e38573e02c28758adb",
                "md5": "33d0872189219ae0715261e7a4f928da",
                "sha256": "38fc1288ec2e8469e25782289674f0b2e0c94abf9475f88208644229e48788a9"
            },
            "downloads": -1,
            "filename": "jsondatafaker-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "33d0872189219ae0715261e7a4f928da",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14964,
            "upload_time": "2023-11-17T16:54:40",
            "upload_time_iso_8601": "2023-11-17T16:54:40.108584Z",
            "url": "https://files.pythonhosted.org/packages/2f/f6/be410d474180cc90fc8843d9df4dd7e658dd81cb31e38573e02c28758adb/jsondatafaker-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "78f351acd62a06d41f38a722d737423620b2b229821bd6491bbc65bf27ad6967",
                "md5": "010bcb0d89f9887c3899185e18efed6f",
                "sha256": "7c2ba7ade9eed2c319555861bc1fd5b9c56d54811cb5a0b23856d4e7be419c11"
            },
            "downloads": -1,
            "filename": "jsondatafaker-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "010bcb0d89f9887c3899185e18efed6f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10389,
            "upload_time": "2023-11-17T16:54:41",
            "upload_time_iso_8601": "2023-11-17T16:54:41.498010Z",
            "url": "https://files.pythonhosted.org/packages/78/f3/51acd62a06d41f38a722d737423620b2b229821bd6491bbc65bf27ad6967/jsondatafaker-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-17 16:54:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "necatiarslan",
    "github_project": "json-datafaker",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2023.7.22"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "3.3.2"
                ]
            ]
        },
        {
            "name": "docutils",
            "specs": [
                [
                    "==",
                    "0.20.1"
                ]
            ]
        },
        {
            "name": "faker-education",
            "specs": [
                [
                    "==",
                    "1.2.1"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.4"
                ]
            ]
        },
        {
            "name": "importlib-metadata",
            "specs": [
                [
                    "==",
                    "6.8.0"
                ]
            ]
        },
        {
            "name": "jaraco.classes",
            "specs": [
                [
                    "==",
                    "3.3.0"
                ]
            ]
        },
        {
            "name": "keyring",
            "specs": [
                [
                    "==",
                    "24.3.0"
                ]
            ]
        },
        {
            "name": "markdown-it-py",
            "specs": [
                [
                    "==",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "mdurl",
            "specs": [
                [
                    "==",
                    "0.1.2"
                ]
            ]
        },
        {
            "name": "more-itertools",
            "specs": [
                [
                    "==",
                    "10.1.0"
                ]
            ]
        },
        {
            "name": "nh3",
            "specs": [
                [
                    "==",
                    "0.2.14"
                ]
            ]
        },
        {
            "name": "pkginfo",
            "specs": [
                [
                    "==",
                    "1.9.6"
                ]
            ]
        },
        {
            "name": "pygments",
            "specs": [
                [
                    "==",
                    "2.16.1"
                ]
            ]
        },
        {
            "name": "readme-renderer",
            "specs": [
                [
                    "==",
                    "42.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.31.0"
                ]
            ]
        },
        {
            "name": "requests-toolbelt",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "rfc3986",
            "specs": [
                [
                    "==",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "rich",
            "specs": [
                [
                    "==",
                    "13.7.0"
                ]
            ]
        },
        {
            "name": "twine",
            "specs": [
                [
                    "==",
                    "4.0.2"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "2.1.0"
                ]
            ]
        },
        {
            "name": "zipp",
            "specs": [
                [
                    "==",
                    "3.17.0"
                ]
            ]
        },
        {
            "name": "faker",
            "specs": [
                [
                    "==",
                    "20.0.3"
                ]
            ]
        },
        {
            "name": "python-dateutil",
            "specs": [
                [
                    "==",
                    "2.8.2"
                ]
            ]
        },
        {
            "name": "pyyaml",
            "specs": [
                [
                    "==",
                    "6.0.1"
                ]
            ]
        },
        {
            "name": "six",
            "specs": [
                [
                    "==",
                    "1.16.0"
                ]
            ]
        }
    ],
    "lcname": "jsondatafaker"
}
        
Elapsed time: 0.35352s