{
"name" : "Randall Johnson",
"street" : "55257 Emanuel Junction",
"city" : "Ryanport",
"zip" : 85646-5766,
"user_name" : "Colt.Gerhold4",
"user_id" : 2902,
"user_id" : "Kaylie_Anderson@yahoo.com",
"favorite_colors" : [
"#066238",
"#2d5617",
"#267d3f",
"#3d141d"
],
"reg_date" : "Sun Dec 18 2011 01:16:06 GMT+0100 (Central European Standard Time)",
"sign_ups" : {
"newsletter" : true
}
}
The Faker.js library is integrated into this JSON generator, and can be used to generate the mock-up data.
Example usage:
{
"name" : "{{faker 'category.entry'}}"
}
This JSON generator uses the Dummy JSON utility in the background. If you familiar with that, you won't have problems using this generator.
You can find the full documentary in the repository on GitHub. I will also list available helpers here, but skip the fake data helpers, since Faker.js is integrated here as well.
This helper can be used to repeat parts of your schema, for instance to fill an array with a certain number of objects.
{
{{#repeat min [max] [comma=false]}}
...
{{/repeat}}
}
min |
The (minimum) number of times the content will be repeated. |
max |
Optional The maximum number of times the item will be repeated. |
comma |
Optional Declare whether repeated items should be separated by a comma or not. |
If both min
and max
are set, a random number in between will be chosen as number of repetitions.
Similar to {{#repeat}}
, {{#optional}}
can be used to repeat a part 0 or 1 times, thus making the part optional.
{
{{#optional}}
"id" : 42
{{/optional}}
}
Note: You now need to place a comma at the beginning or end of your optional block, depending on your surrounding schema, to avoid syntax errors.
The snippet above can create either of the following outputs:
{}
{
"id" : 42
}
Generating a random integer number between the given limits.
{{int min max [format] [round=1]}}
min |
Lower number for the generated integer number. |
max |
Upper limit for the generated integer number. |
format |
Optional - String format for the number, such as "0,0" to generate a number like 42,000 . Supported formats can be found at numbrojs.com/format.html |
round |
Optional - Rounds to the closest multiple of the given number. |
Identical to int
(see above), except float
is generating a float value.
{{float min max [format] [round=1]}}
Generating a random date from the given date range.
{{date min max [format]}}
min |
Earliest day to be generated. |
max |
Latest day to be generated. |
format |
Optional - String format for the date, such as "MM/DD/YYYY" . The default is null and generates a date string such as Thu May 31 2018 03:14:15 GMT+0000 (GMT) Supported formats can be found at github.com/taylorhakes/fecha |
This generates a random time from the given time range.
{{time min max [format]}}
min |
Earliest time to be generated. |
max |
Latest time to be generated. |
format |
Optional - String format for the date, such as "HH:mm:ss" . The default is null and generates a date string such as 13:37 Supported formats can be found at github.com/taylorhakes/fecha |
This helper generates a random boolean value of true
or false
.
{{boolean}}
This is website is using some third-party projects and tools. Surprising, right?