有没有一种方法可以在变量中创建伪造的json数据,然后在getJSON方法中调用它?例如:
//$(document).ready(function () {
// $.getJSON("/user", function (obj) {
var obj = {
users: [
{
id: 0
, firstname: "Adolf"
, secondaryname: "Harvey"
, phone: "1-778-605-9725 x341"
, address: "54001 VonRueden Course"
}
, {
id: 1
, firstname: "Cheyanne"
, secondaryname: "Bradtke"
, phone: "067.058.4419 x8766"
, address: "63788 Moen Green"
}
, {
id: 2
, firstname: "Llewellyn"
, secondaryname: "Jacobi"
, phone: "(253) 989-2943"
, address: "41407 Buckridge Ports"
}
]
};
$.each(obj.users, function (key, value) {
$("#usernames").append(value.firstname);
console.log(value.firstname);
});
// });
//});
以上是否可能使用伪造数据(faker.name.findName())?