将Faker数据放入变量

时间:2018-11-29 09:59:57

标签: javascript jquery json faker

有没有一种方法可以在变量中创建伪造的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())?

0 个答案:

没有答案