https://github.com/berquerant/randomjson
Random json generator.
https://github.com/berquerant/randomjson
python
Last synced: 8 months ago
JSON representation
Random json generator.
- Host: GitHub
- URL: https://github.com/berquerant/randomjson
- Owner: berquerant
- License: mit
- Created: 2022-10-14T09:32:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-28T07:45:03.000Z (over 3 years ago)
- Last Synced: 2025-03-31T11:31:18.839Z (about 1 year ago)
- Topics: python
- Language: Python
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# randomjson
Generate random json.
# Example
example.json:
``` json
{
"schema": {
"items": [
"{{repeat}}",
"{{variable|n}}",
{
"user_id": [
"{{function|uuid}}"
],
"action": [
"{{function|choice}}",
"{{variable|actions}}"
],
"url": [
"{{function|format}}",
"{{variable|url_template}}",
[
"{{function|rand}}",
"{{const|100|int}}"
]
],
"ref": [
"{{cond}}",
[
[
"{{function|eq}}",
[
"{{function|rand}}",
"{{const|1|int}}"
],
"{{const|1|int}}"
],
[
"{{function|format}}",
"{{variable|ref_template}}",
[
"{{function|rand}}",
"{{const|100|int}}"
]
]
]
]
}
]
},
"variables": {
"actions": [
"pageview",
"click",
"conversion"
],
"n": 3,
"url_template": "https://sample{}.com",
"ref_template": "https://sample{}.com/ref"
}
}
```
`python -m randomjson.cli @example.json` generates below:
``` json
{
"items": [
{
"user_id": "2d324eb1-0770-4444-bea8-d3de536da168",
"action": [
"conversion"
],
"url": "https://sample3.com"
},
{
"user_id": "526a4ca9-6b5a-483f-9869-8935c5524408",
"action": [
"pageview"
],
"url": "https://sample16.com"
},
{
"user_id": "7f2b8a89-cf75-4316-9152-07792b5830fc",
"action": [
"click"
],
"url": "https://sample85.com",
"ref": "https://sample49.com/ref"
}
]
}
```