Сообщение от Зосимов
|
спасибо. но выходят 0 везде почему то
когда я делаю alert(data) то выводятся строки:
{"name":"John","lastName":"Doe","age":35,"gende r":"Male","department":"English","car":"Honda"}
{"name":"John","lastName":"Doe","age":35,"gender": "Male","department":"English","car":"Honda"}
{"name":"John","lastName":"Doe","age":35,"gender": "Male","department":"English","car":"Honda"}
{"name":"John","lastName":"Doe","age":35,"gender": "Male","department":"English","car":"Honda"}
{"name":"John","lastName":"Doe","age":35,"gender": "Male","department":"English","car":"Honda"}
вот эти строки, я хотел привести к нормальном виду. желательно даже в <li> как то загнать каждую строку
|
набросок
var data = `{"name":"John","lastName":"Doe","age":35,"gende r":"Male","department":"English","car":"Honda"}
{"name":"John","lastName":"Doe","age":35,"gender": "Male","department":"English","car":"Honda"}
{"name":"John","lastName":"Doe","age":35,"gender": "Male","department":"English","car":"Honda"}
{"name":"John","lastName":"Doe","age":35,"gender": "Male","department":"English","car":"Honda"}
{"name":"John","lastName":"Doe","age":35,"gender": "Male","department":"English","car":"Honda"}
`;
alert(data.trim().split(/\r?\n/).map(function(item) {
var data = JSON.parse(item);
return data.name + ' | ' + data.lastName;
}).join('\n'));