I"m using chance.js to help me generate some random data. It works really well, and I'd like to use this data to output random JSON objects.
Here's the structure I'm after:
{
"users": [
{
"Name": "John Smith",
"Fname": "John",
"Lname": "Smith",
"Email": "john.smith@acmemedia.com",
},
...etc
}
I have chance.js working in a jsFiddle, but I'm not sure how to output JSON data with the chance.js
functions.
$(function() {
$("div[data]").each(function() {
var data = $(this).attr("data");
var chance = new Chance(Math.Random);
$(this).append(chance[data]());
});
});
http://jsfiddle.net/5Lcfz838/4/
The chance.js documentation is available here: http://chancejs.com/