https://github.com/tidwall/randjson
Make random JSON in Go
https://github.com/tidwall/randjson
Last synced: 9 months ago
JSON representation
Make random JSON in Go
- Host: GitHub
- URL: https://github.com/tidwall/randjson
- Owner: tidwall
- License: mit
- Created: 2020-02-08T18:05:25.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-09T15:10:04.000Z (almost 6 years ago)
- Last Synced: 2025-04-05T03:12:26.237Z (9 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 25
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `randjson`
[](https://pkg.go.dev/github.com/tidwall/randjson)
Make random JSON in Go
## Usage
Get the package
```
go get github.com/tidwall/randjson
```
Make some random JSON using the default options and a maximum of 12 nested child
elements.
```go
js := randjson.Make(12, nil)
println(string(js))
```
Outputs:
```json
{
"interlocal": true,
"subterjacent": null,
"unpalpitating": false,
"semitruth": null,
"democratical": "becher",
"extrapoetical": null,
"sympathetically": null,
"townless": [true],
"glisten": null,
"unverifiedness": null,
"polariscopy": {
"ayacahuite": {
"vertebrocostal": true,
"Langhian": [false, 89.32, null],
"bubo": "albe",
"avoidless": "unconsolatory",
"revitalize": true,
"brassiness": true
},
"booksellerish": true,
"unduplicable": 44.49,
"overtopple": {
"sclerometer": "reune",
"unbelt": false,
"personalia": {
"epeirogenic": "epeirogenic"
},
"scutellated": "unfroward"
},
"muffishness": false,
"preignition": [true, "ramus", null, false],
"evangeliarium": null,
"ardri": 24.53,
"playfulness": null
},
"playfulness": {
"mumper": [],
"contriturate": "avoidless"
}
}
```
## Options
```go
type Options struct {
// Pretty formats and indents the random json. Default true
Pretty bool
// Words are the number of unique words to use. Default 1,000
Words int
// Rand is the random number generator to use. Default global rng
Rand *rand.Rand
}
```