All Projects → tidwall → randjson

tidwall / randjson

Licence: MIT license
Make random JSON in Go

Programming Languages

go
31211 projects - #10 most used programming language

randjson

GoDoc

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.

js := randjson.Make(12, nil)  
println(string(js))

Outputs:

{
  "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

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
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].