4.2: Generating Seed Data
We need some Users to begin adding more features.
We could manually register users, enter their profile information, find photos for them, etc.
But, we're programmers. We're lazy.
We can do it with less effort.
json-generator.com
One option for generating seed data is www.json-generator.com. It's the method we'll be using.
There are many other options like the npm Faker library or the NuGet package. Feel free to experiment with those as well.
Navigate to www.json-generator.com and have a look around the site.
Click the 'Help' button and see a list of options we can use to generate data. It has a lot - generating integers, strings, bools, etc. as well as more interesting data generation like lorem ipsum, companies, emails, phone numbers, etc. You can also write custom functions to generate data - which is what we'll do for photos.
We need to generate two sets of data - for males and females (so their names and photos align). And we'll generate 25 of each and then combine them into a single .json file
Ladies first:
Now, change out 'female' to 'male' in the Username value and change 'women' to 'men' in the api call and run it again:
Now, combine the two JSON results into a single file.
Alternatively, you can use the JSON data provided in the project GitHub repository.
If you want to verify you combine the two correctly, use a JSON validator like this one.
Save it in your .Data
project as UserSeedData.json.
Last updated