Generate fake data that don't change [closed]

偶尔善良 提交于 2021-01-29 07:50:51

问题


I'm creating a temporary GraphQL backend, that should serve mocked data.

E.g. I need ~500 objects of the model Person (with firstName, lastName, email, country, etc), where the properties shouldn't change on each request.

Is there any library where it's possible to get fake data always created in the same order?


回答1:


You can easily create your custom JSON with https://next.json-generator.com/ which allows using internal scripts for data generation

Here is an example of generating a list of names: https://next.json-generator.com/Vk95XL5mv




回答2:


Not sure if this is exactly what you want, but I discovered this site: https://crudpi.io/ this weekend, you can mock some data in a JSON file and use it for your API. I guess that it's limited to 100 objects or something, but if you need the same data, you can copy it 5 times I guess. Hope it helps!

I wish that I could write this as a comment but I don't have enough reputation yet.




回答3:


Here's an API. https://uinames.com/api/?amount=500

You should easily just create a script, add the data you got from this to a temp-database.




回答4:


You can use a generator like https://randomuser.me/ Make a loop to create your object then keep the result in a file to ensure the data will be the same.

You can get an exemple here : https://gist.github.com/Yexan/cb8b79390e01272a4912fb4d6773ee1a

I used https://randomuser.me/api/?results=500



来源:https://stackoverflow.com/questions/57461696/generate-fake-data-that-dont-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!