5 ms·
Show HN: Generate JSON mock data for testing/initial app development
- smalu 3y agoUsing real domains (like yahoo.com) for "fake" e-mail address is not a good practice. There are domains like example.com, example.net or example.org for such purposes (RFC 2606, RFC 6761).
- tobr 3y agoThat depends on what you’re trying to do. If you want it to be an obvious example, @example.com is great. If you want it to look like real data, such as in a demo or a screenshot, it’s not so great. It’s a bit like saying that every demo user should be called John Doe or Jane Doe if they aren’t actual people.
- terpimost 3y agoIs it using https://fakerjs.dev/ https://fakerjs.dev/ ?
- Nickba 3y agoNot completely but for a good portion of it.
- infixed 3y agoThere was an interesting thread that did the rounds on HN a couple years back about using Faker in a related (but different) product. https://news.ycombinator.com/item?id=27252066 https://news.ycombinator.com/item?id=27252066 Personally, I think your demo has a pretty neat / novel UX. I couldn't find a way to generate a large number of examples at once -- did I miss that somewhere?
- Nickba 3y agoSo you should be able to use the repeat(numberOfTimes?) tag to generate an N number of examples. I believe I set the max now to 20. But as long as the first index in an array is repeat(), anything in the second index will repeat N amount of times.
- danielvaughn 3y agoI've been using ChatGPT for this and it produces really good results, though of course the back-and-forth is a bit clunky. Would be great to build it into a more streamlined experience.
- awesomehry 3y agoA friend of mine built a tool called Trex that you might find helpful, check it out here: https://github.com/automorphic-ai/trex https://github.com/automorphic-ai/trex It's very consistent at generating templated data.
- Alifatisk 3y agoI assume Trex requires an internet connection the way it works?
- awesomehry 3y agoYes, using the API requires an internet connection but I believe you can also contact them (founders@automorphic.ai) to self-host on your own machine.
- btwillard 3y agoWe provide this in https://github.com/outlines-dev/outlines https://github.com/outlines-dev/outlines.
- deleted 3y ago[deleted]
- HappyMedium326 3y agonice little tool
- giobox 3y agoThis is nice, but trivial to accomplish with the “faker” library available for most major programming languages - almost all reasonable web test frameworks will allow you to just make this json locally with the generated values, often with almost the exact same/extremely similar template syntax shown here.
- monkpit 3y agoThere’s also json-schema-faker which is pretty cool. https://github.com/json-schema-faker/json-schema-faker https://github.com/json-schema-faker/json-schema-faker
- darnfish 3y agoIs there an API for this? Much more useful to have a script that generates 10k mock objects and inserts into a database than generating in this web UI and copy/pasting :~)
- Nickba 3y agoHoping to add that feature in. Not sure on the timeline.
- harry_1989 3y agoIs there a similar tool to generate API responses once you have an OpenAPI spec? Sort of a mock server, that can give out responses as per spec and occasionally induce errors. This will be helpful in decoupling frontend and backend during initial development.
- m13z 3y agoI use https://stoplight.io/open-source/prism https://stoplight.io/open-source/prism with x-faker properties in my OpenAPI specs to mock APIs with dynamic content.
- tangoalpha 3y ago"location": { "street": "853 Watsica Flat", "city": "North Biankaview", "state": "Wisconsin", "country": "India", "zip": "72621-2558", "coordinates": { "latitude": 6.5434, "longitude": -152.386 } Could be a useful tool if this location data is coherent. State, City, Zip, Country and Lat/Lon are each of different places.
- ivanche 3y agoA friend and I had started a project similar to this some 6-7 years ago. We wanted to make all the generated data consistent so if, for example, you need data about German person it would return real city name, real (or at least plausible) street name, postal number, phone numbers both mobile and fixed with the proper country and operators code, email address using national domain, personal name was chosen out of plausible names for each country etc. etc. In the end it was so much work that we abandoned it :(
- sgarland 3y agoI have a similar project that generates random SQL rows, and yes, getting everything consistent is a huge pain. Mine generates city/country pairs that match, and has a limited set of countries that it will also generate matching phone numbers for. It ignores area/operator code differences. Email addresses, it uses first.last@$RANDOM.com, no country-specific. The other struggle I have is that to properly test a DB, you need millions of rows, not thousands. Mine does quite well up through a few million, but then starts struggling. I need to overhaul the generator functions to use threading. I hadn’t initially because I assumed the CPU would be too busy to context switch, but then I tried a smaller example and found I was wrong - massive speed up.
- netsharc 3y agoYeah.. name, username, and 2 email addresses being different to one another is also irritating.. probably it's taxing for the brain if say testing with the user "brian.duncan" shows an exception in the UI, and then when scrolling through the logs one has to remember his email is "donna.tella@versace.it"... "name": { "first": "Shayna", "middle": "Quinn", "last": "Harris" }, "username": "Burnice.Lehner27", "password": "o7DioxYA810KFBR", "emails": [ "Sabryna_Roberts13@hotmail.com", "Stephen.Tremblay@gmail.com" ],
- LauraMedia 3y agoReally great project! I think there are three small functions that would be great additions: * IP's (V4, V6) * Enums (maybe something like enum('active', 'inactive', 'removed').) * Texts (like blog titles or description fields)
- Nickba 3y agoIPs and Enums added.
- osullip 3y agoIs there a generator for all the JSON generators out there? https://json-generator.com/ https://json-generator.com/ https://www.objgen.com/json/local/design https://www.objgen.com/json/local/design https://www.atatus.com/tools/json-generator https://www.atatus.com/tools/json-generator https://www.site24x7.com/tools/json-generator.html https://www.site24x7.com/tools/json-generator.html Not discounting the effort it takes to build a tool like this. It has, however, been done to death.